#include <Servo.h>
Servo servo1;
Servo servo2;
const int switch1 = 2;
void setup(){
servo1.attach(3);
servo2.attach(5);
servo1.write(0);
servo2.write(0);
pinMode(switch1, INPUT);
}
void loop(){
int i;
int sw = digitalRead(switch1);
if (sw == HIGH){
for(i=0; i<=180; i += 2.5){
servo1.write(i);
servo2.write(i);
delay(100);
}
for(i=180; i>=0; i -= 2.5){
servo1.write(i);
servo2.write(i);
delay(100);
}
}
else if (sw == LOW) { servo1.write(i);
servo2.write(i);
}
}