#include <Servo.h>
Servo Servo1;
//Servo Servo2; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
Servo1.attach(3);
//Servo2.attach(6); // attaches the servo on pin 9 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
Servo1.write(pos); // tell servo to go to position in variable 'pos'
// Servo2.write(pos);
delay(30); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 60; pos -= 1) { // goes from 180 degrees to 0 degrees
Servo1.write(pos); // tell servo to go to position in variable 'pos'
//Servo2.write(pos);
delay(30);
}
// waits 15ms for the servo to reach the position
}