Hi everyone,
As the title states: "My 4 servos are all turning simultaneously with one Potentiometer" That is not the way the project is suppose to work.
Each servo is to work independently of the other 3, with its own potentiometer.
I don't know what is happening..but here is the code, I am hoping someone can help me with this.
CODE:
#include <Servo.h>
Servo myservo0; // create servo object to control a servo
Servo myservo1; // i added
Servo myservo2; // i added
Servo myservo3; // i added
int potpin0 = 0; // analog pin used to connect the potentiometer (i added the zero to the potpin before the equal sign)
int val0; // variable to read the value from the analog pin
int potpin1 = 1; // i added
int val1; // i added
int potpin2 = 2; // i added
int val2; // i added
int potpin3 = 3; // i added
int val3; // i added
void setup()
{
myservo0.attach(3); // attaches the servo on pin 9 to the servo object
myservo1.attach(5); // i added
myservo2.attach(6); // i added
myservo3.attach(9); // i added
}
void loop()
{
val0 = analogRead(potpin0); // reads the value of the potentiometer (value between 0 and 1023)
val0 = map(val0, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo0.write(val0); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
val1 = analogRead(potpin1); // i added
val1 = map(val1, 0, 1023, 0, 179); // i added
myservo1.write(val1); // i added
delay(15);
val2 = analogRead(potpin2); // i added
val2 = map(val2, 0, 1023, 0, 179); // i added
myservo2.write(val2); // i added
delay(15);
val3 = analogRead(potpin3); // i added
val3 = map(val3, 0, 1023, 0, 179); // i added
myservo3.write(val3); // i added
delay(15);
}
Thank you in advance for any and all assistance I may receive.
Anna