#include <Servo.h>
Servo servo1, servo2; // create servo object to control a servo
#define SWITCH_PIN 7
#define SERVO1_PIN 9
#define SERVO2_PIN 6
void setup() {
pinMode(SWITCH_PIN,INPUT);
servo1.attach(SERVO1_PIN); // attaches the servo on pin 9 to the servo object
servo2.attach(SERVO2_PIN); // attaches the servo on pin 9 to the servo object
}
void loop() {
if (digitalRead(SWITCH_PIN) == LOW) { // reads the value of the potentiometer (value between 0 and 1023)
servo1.write(0);
servo2.write(0);
} else {
servo1.write(180);
servo2.write(180);
delay(500);
} // waits for the servo to get there
}