#include <Servo.h>
Servo myservoa; // create servo object to control a servo
Servo myservob; // create servo object to control a servo
int potpina = A0; // analog pin used to connect the potentiometer
int vala; // variable to read the value from the analog pin
nt potpinb = A1; // analog pin used to connect the potentiometer
int valb; // variable to read the value from the analog pin
void setup() {
myservoa.attach(9); // attaches the servo on pin 9 to the servo object
myservob.attach(10);
}
void loop() {
vala = analogRead(potpina); // reads the value of the potentiometer (value between 0 and 1023)
vala = map(vala, 0, 1023, 0, 180); // scale it for use with the servo (value between 0 and 180)
myservoa.write(valb); // sets the servo position according to the scaled value
valb = analogRead(potpinb); // reads the value of the potentiometer (value between 0 and 1023)
valb= map(valb, 0, 1023, 0, 180); // scale it for use with the servo (value between 0 and 180)
myservob.write(valb); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}