#include <Servo.h>
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
#include <Servo.h>
Servo myservo1; // create servo object to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
int potpin1 = 0; // analog pin used to connect the potentiometer
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int val1; // variable to read the value from the analog pin
int val2;
int val3;
int val4;
void setup()
{
myservo1.attach(3); // attaches the servo on pin 9 to the servo object
myservo1.attach(5);
myservo1.attach(6);
myservo1.attach(9);
}
void loop()
{
val1 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
(it comes here)
val1 = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
val2 = analogRead(potpin2); // reads the value of the potentiometer (value between 0 and 1023)
val2 = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val); // sets the servo position according to the scaled value
delay(15);
val3 = analogRead(potpin3); // reads the value of the potentiometer (value between 0 and 1023)
val3 = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val); // sets the servo position according to the scaled value
delay(15);
val4 = analogRead(potpin4); // reads the value of the potentiometer (value between 0 and 1023)
val4 = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val); // sets the servo position according to the scaled value
delay(15);