Hi
another rookie question about coding with arduino
i simple need to make arduino to count from 0 to 180 with steps of 10 when it reach 180 I want that start to count from 180 to 0 and again again
I wrote this:
#include <Servo.h>
Servo myServo;
int const potPin = A0;
int angleForced=0;
void setup() {
myServo.attach(9);
Serial.begin(9600);
}
void loop() {
Serial.print("angleFORCED: ");
Serial.print(angleForced);
if (angleForced < 179){
angleForced=angleForced+10;
} else if (angleForced >=179){
angleForced=angleForced-10;
}
myServo.write(angleForced);
delay(1000);
}
the problem in the code is:
when it reach 180 it count down to 170 and I get in to a loop of 180 170 180 numbers.
What I want is 0 10 20 30 ....to 180 170 160 ...to 0 etc etc
Cheers
D