Servo jerking around in 6DOF robotic arm

Hi
I have created a 6DOF robotic arm using servos and controlled by 10K pots, these are powered through a servo shield and supplied with 6V DC power. This is essentially run in isolation to arduino by bending away the 5V pin on shield and jumping the power on the shield, that way I an also run 9V to power the arduino. The issue is that when I switch everything on the servos go ‘nuts!’ jerking and twitching all the time can still move the servos with the respective pots but the shaking is really quite violent. I have attached the code below, any assistance would be greatly appreciated.
Thanks

#include <Servo.h>

Servo base13;
Servo base25;
Servo shoulder6;
Servo elbow9;
Servo wrist11;
Servo hand12;

int potpin0 = 0;
int potpin = 1;
int potpin2 = 2;
int potpin3 = 3;
int potpin4 = 4;
int potpin5 = 5;

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

void setup()
{
base13.attach(3);
base25.attach(5);
shoulder6.attach(6);
elbow9.attach(9);
wrist11.attach(11);
hand12.attach(12);
}

void loop()
{

val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
base13.write(val);
delay(5);
val2 = analogRead(potpin2);
val2 = map(val2, 0, 1023, 0, 179);
base25.write(val2);
delay(5);
val3 = analogRead(potpin3);
val3 = map(val3, 0, 1023, 0, 179);
shoulder6.write(val3);
delay(5);
val4 = analogRead(potpin4);
val4 = map(val4, 0, 1023, 0, 179);
elbow9.write(val4);
delay(5);
val5 = analogRead(potpin5);
val5 = map(val5, 0, 1023, 0, 179);
wrist11.write(val5);
delay(5);
val0 = analogRead(potpin0);
val0 = map(val0, 0, 1023, 0, 179);
hand12.write(val0);
delay(5);
}

AaronC: these are powered through a servo shield and supplied with 6V DC power.

Servos can take a surprising about of power. What sort of power supply are you using?

Take a look at this recent thread for information about controlling servos in a robot arm.

As you can see from the thread, gyrojeremy had trouble powering all the servos in his arm. Fortunately he got everything worked out and ended up with a great robot.

Hopefully the joystick/servo code I shared in the other thread will be useful in your project. If you decide to try the code, let me know if you need help modifying it for your setup.

Thanks for the quick reply. Am powering the servos through simple DC power supplies (battery). Am pretty new to this and have had limited success in getting these more advanced projects to work effectively first time. I can no exactly see how I would be able to modify my code to work with what I am doing with the joystick controller code you posted...

How many amps can your battery supply?

simple DC power supplies (battery)

[u]Fresh[/u] AA batteries can power [u]at most[/u] two servos.

AaronC: I can no exactly see how I would be able to modify my code to work with what I am doing with the joystick controller code you posted...

Sorry, I hadn't given you a direct link to the code I think you should try.

The code attached to this post, can easily be modified to use as many pots and servos as you have analog inputs.

I marked the arrays you'll need to modify with the comment "**** Number of elements should match "SERVOS_IN_USE" ****"

I tried to add comments about the various parameters you can set in the constant section.