Controlling 6 servos with Serial Monitor- problem

Hello,
I am trying to control 6 servos in a robotic arm using arduino. I’m trying to trigger them using the Serial Monitor, but when I start the Arduino, the servos simply jitter a little and don’t respond to any commands sent by Serial Monitor. Does anyone know why this is? My code is below:

#include <Servo.h>

Servo finger;
Servo finger2;
Servo fingerR;
Servo elbow;
Servo wrist;
Servo rotation;

int posfinger = 0;
int posfinger2 = 0;
int posfingerR = 180;
int poselbow = 0;
int poswrist = 75;
int posrotation = 20;

void setup() {
finger.attach(3);
finger2.attach(4);
fingerR.attach(10);
elbow.attach(5);
wrist.attach(8);
rotation.attach(9);

finger.write(posfinger);
finger2.write(posfinger2);
fingerR.write(posfingerR);
elbow.write(poselbow);
wrist.write(poswrist);
rotation.write(posrotation);

Serial.begin(19200);
}

void loop() {
if (Serial.available() > 0) {
int inByte = Serial.read();

if (inByte == ‘q’) {
poselbow = 170;
elbow.write(poselbow);

delay(2500);

poselbow = 0;
elbow.write(poselbow);

} else if (inByte == ‘w’) {
posfinger = 0;
posfinger2 = 0;
posfingerR = 180;

finger.write(posfinger);
finger2.write(posfinger2);
fingerR.write(posfingerR);

delay(1000);

posfinger = 180;
posfinger2 = 180;
posfingerR = 0;

finger.write(posfinger);
finger2.write(posfinger2);
fingerR.write(posfingerR);

delay(1000);

posfinger = 0;
posfinger2 = 0;
posfingerR = 180;

finger.write(posfinger);
finger2.write(posfinger2);
fingerR.write(posfingerR);

} else if (inByte == ‘e’) {
poswrist = 75;
wrist.write(poswrist);

delay(1000);

poswrist = 150;
wrist.write(poswrist);

delay(1000);

poswrist = 75;
wrist.write(poswrist);
} else if (inByte == ‘r’) {
posrotation = 20;
rotation.write(posrotation);

delay(1000);

posrotation = 180;
rotation.write(posrotation);

delay(1000);

posrotation = 20;
rotation.write(posrotation);
}
}
}

There does not appear to be any problem with your code. Therefore, the problem must be with the hardware. How are the servos being powered?

I have the signal (white wire) from the servos attached to their respective pins on the Arduino. I then connect the the ground and V+ wires from the servo to the terminals of a 6v battery, then tie the ground of the arduino and the ground of the battery together.

I was thinking maybe it was the need to call a refresh from the servo, but it arduino 0021 doesn't recgonize the refresh function.

Thanks for your reply

The refresh is done automatically by the Servo library.

Are you able to get one servo to move using the Servo sweep example sketch?

Yes- I am able to get each servo to individually move using the sweep sketch as well as an edited version of the above sketch. I am able to run the above code when there is only one or two motors, but when 6 get involved the only thing that happens is that they jitter a little and move to arbitrary positions. I know the power source is large enough because the max draw of all servos of any one time(with load) was ~6 amps and the battery gave a max on my multimeter of 8 amps.

How low has the voltage to the servos dropped when they are jittering? If you can disconnect some of the servos and the rest start to work ok, then it does sound like a low voltage issue.

and the battery gave a max on my multimeter of 8 amps.

How did you measure this?

I agree with zoomkat. This sounds like a low current issue.