#include <Servo.h>
// Create the servo object to control a servo.
// Up to 12 servo objects can be created on most boards.
Servo myservo;
Servo myservo2 ;
void setup() {
// Attach the servo on pin 9 to the servo object
myservo.attach(9);
}
void loop() {
// Go from 0 degrees to 180 degrees
// Move in steps of 1 degree
for (int angle = 0; angle <= 90; angle += 3) {
// Tell servo to go to the position in variable 'angle'
// where 'angle' is in degrees
myservo.write(angle);
// Wait 15 milliseconds for the servo to get to the position
delay(10);
}
// Go from 180 degrees to 0 degrees
// Move in steps of 1 degree
for (int angle = 90; angle >= 0; angle -= 1) {
// Tell servo to go to the position in variable 'angle'
// where 'angle' is in degrees
myservo.write(angle);
// Wait 15 milliseconds for the servo to get to the position
delay(10);
}
// Go from 0 degrees to 180 degrees
// Move in steps of 1 degree
for (int angle = 0; angle <= 130; angle += 1) {
// Tell servo to go to the position in variable 'angle'
// where 'angle' is in degrees
myservo.write(angle);
// Wait 15 milliseconds for the servo to get to the position
delay(8);
}
// Go from 180 degrees to 0 degrees
// Move in steps of 1 degree
for (int angle = 130; angle >= 0; angle -= 1) {
// Tell servo to go to the position in variable 'angle'
// where 'angle' is in degrees
myservo.write(angle);
// Wait 15 milliseconds for the servo to get to the position
delay(8);
}
}