#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
int potpin1 = 0;
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int potpin5 = 4;
int val1;
int val2;
int val3;
int val4;
int val5;
void setup() {
// put your setup code here, to run once:
servo1.attach(3);
servo2.attach(5);
servo3.attach(6);
servo4.attach(9);
servo5.attach(10);
}
void loop() {
// put your main code here, to run repeatedly:
val1 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val1 = map(val1, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
servo1.write(val1); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
val2 = analogRead(potpin2);
val2 = map(val2, 0, 1023, 0, 180);
servo2.write(val2);
delay(15);
val3 = analogRead(potpin3);
val3 = map(val3, 0, 1023, 0, 180);
servo3.write(val3);
delay(15);
val4 = analogRead(potpin4);
val4 = map(val4, 0, 1023, 0, 180);
servo4.write(val4);
delay(15);
val5 = analogRead(potpin5);
val5 = map(val5, 0, 1023, 0, 180);
servo5.write(val5);
delay(15);
}