Servo Help!! Urgent.

Hello all,

Me and my friend are attempting to build a robotic arm. We have 4 main servos which when attached to the power source (6v-7.5 amp) twitch violently back and forth. We've messed with the code, and even tried attaching it to arduino power itself but they dont seem to work correctly. Code:

#include <Servo.h>

Servo myservo;
Servo myservo2;
Servo myservo3;
Servo myservo4;

int potpin = 1;
int potpin2 = 2;
int potpin3 = 3;
int potpin4 = 4;

int val = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;

void setup ()

{
myservo.attach(52);
myservo2.attach(47);
myservo3.attach(42);
myservo4.attach(37);

}

void loop()

{

val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
myservo.write(val);
delay(5);

val2 = analogRead(potpin2);
val2 = map(val2, 0, 1023, 0, 179);
myservo2.write(val2);
delay(5);

val3 = analogRead(potpin3);
val3 = map(val3, 0, 1023, 0, 179);
myservo3.write(val3);
delay(5);

val4 = analogRead(potpin4);
val4 = map(val4, 0, 1023, 0, 179);
myservo4.write(val4);
delay(5);

}

Hopefully someone out there could help us out with debugging this thing, need answers asap since we're hard pressed for time.

What board are you using?

When the servos are connected to a separate power source, are the arduino and power sources grounds connected?

Also, please use code tags when posting code.

I suggest you check whether your servos are actually capable of 180 degrees of movement, most of them are not.

Try a capacitor! I have a 25v 2200uf cap on my robotic arm. It takes a lot of twitch out. Had the exact same thing happen to me. And you HAVE TO ground to a common source. All of my servo grounds, and external grounds go to the arduino. If you don't, it will not work well, if at all.

You may have too much load on the servos and they are hunting. Do the servos twitch when they are not loaded? If only one servo is being powered and the rest disconnected, does the connected servo still twitch?

Yesterday I discovered (based on something I read on another forum) that putting a resistor from the signal to the ground connection of the servo (which holds the signal low) has stopped it acting wildly when there is no signal applied. I've used a 4k7 resistor. If that doesn't work it might be worth putting the resistor between signal and power (i.e. holding the signal line high).

...R