this code runs 3 of the servos like a champ but when i add in the 4th one i got all the same problems, so i chained the code to work the other servo and not the first one i tryed and those 3 ran like a champ. man 1, 2, 3 servos ok, but 4 no way
#include <MegaServo.h>
MegaServo servo1;
MegaServo servo2;
\\ see i cut servo3
MegaServo servo4; // the frist time i cut servo 4 and left in 3
int potpin1 = 0; // analog pin used to connect the potentiometer
int potpin2 = 1;
int potpin4 = 3;
int val; // variable to read the value from the analog pin
void setup()
{
servo1.attach(9); // attaches the servo on pin 9 to the servo object
servo2.attach(10); // attaches the servo on pin 10 to the servo object
servo4.attach(11);
}
void loop()
{
val = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
servo1.write(val); // sets the servo position according to the scaled value
val = analogRead(potpin2); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 179, 0); // scale it to use it with the servo (value between 0 and 180)
servo2.write(val);
val = analogRead(potpin4); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
servo4.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}