Hello,
I have used the code below to control a servo using a potentiometer. I need to now do the same but with multiple servos and potentiometers. I am using the ANALOG 0 and DIGITAL 9 PINS on the Arduino. I am very new to this and need help knowing what I need to and don't need to duplicate in the program. I need to do a total of 3 servos.
Thanks a lot!!
p.s. does anyone know how to power three servos separately from the arduino with a adapter they are rated 6v each. Let me know.
#include <Servo.h>
Servo arm; // create servo object to control a servo
int armpin = 0; // analog pin used to connect the potentiometer
int armval; // variable to read the value from the analog pin
void setup()
{
arm.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
armval = analogRead(armpin); // reads the value of the potentiometer (value between 0 and 1023)
armval = map(armval, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
arm.write(armval); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}