#include <Servo.h>
Servo myservo1, myservo2, myservo3; // create servo object to control a servo
int potpin = A0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int i = 0;
void setup() {
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(10); // attaches the servo on pin 9 to the servo object
myservo3.attach(11); // attaches the servo on pin 9 to the servo object
}
void loop() {
delay(1000);
val = 500 * i ;// analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
i = !i;
val = map(val, 0, 1023, 0, 180); // scale it for use with the servo (value between 0 and 180)
myservo1.write(val); // sets the servo position according to the scaled value
myservo2.write(val+15);
myservo3.write(val+30);
delay(15); // waits for the servo to get there
}