Trying to run a sweep program, but the servo will not repeat the sweep. The code switches back and forth, observed through the serial monitor, but the actual motor will not operate accordingly. I am running a sample program from the arduino but I have translated the minor things. Here's my code.
_________________________________________________________________________________________
const int servoPin = 11;
double pos = 0;
void setup()
{
pinMode(servoPin, PWM);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
pwmWrite(servoPin, pos); // tell servo to go to position in variable 'pos'
delay(15);
SerialUSB.print("\n CW");
delay(20); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
pwmWrite(servoPin, pos); // tell servo to go to position in variable 'pos'
delay(15);
SerialUSB.print("\n CCW");
delay(20); // waits 15ms for the servo to reach the position
}
}
_______________________________________________________________________________