Hi,
Trying to set up my IDE to sweep 2 servos smoothly.
Got lots of bugs apparently. Servos are herky jerky and not sweeping smoothly at all. Would greatly appreciate a look see.Im sure its something simple Im not seeing. Amount of degrees in movement not my concern. Just wanting the servos to do it smoothly in both directions.
Thanks so much
Sweep 2 servos from 0 to 40 degrees and back to 0
#include <Servo.h>
Servo servo1; // create servo object to control a servo
Servo servo2; // create servo object to control a servo
int pos = 0; // variable to store the servo position
void setup(){
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(10); // attaches the servo on pin 10 to the servo object
}
void loop()
}
for(pos = 60; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees
}
// in steps of 1 degree
myservo1.write(pos); // tell servo to go to position in variable ‘pos’
delay(50); // waits 15ms for the servo to reach the position
}
for(pos = 60; pos>=20; pos-=1) // goes from 180 degrees to 0 degrees
}
myservo1.write(pos); // tell servo to go to position in variable ‘pos’
delay(50); // waits 15ms for the servo to reach the position
}
for(pos = 60; pos>=20; pos-=1) // goes from 180 degrees to 0 degrees
myservo2.write(pos); // tell servo to go to position in variable ‘pos’
delay(50); // waits 15ms for the servo to reach the position
}
for(pos = 20; pos <= 90; pos += 1) // goes from 0 degrees to 180 degrees} // in steps of 1 degree
}
myservo1.write(pos); // tell servo to go to position in variable ‘pos’
delay(60); // waits 15ms for the servo to reach the position
}
for(pos = 90; pos>=20; pos-=1) // goes from 180 degrees to 0 degrees
}
myservo2.write(pos); // tell servo to go to position in variable ‘pos’
delay(70);
}
}