How to resolve motor stuttering.

I’m currently building a controller for six servo motors controlled by potentiometers off of an arduino mega. I’m almost complete, but recently I’ve been getting a great deal of dithering and multiple motors attempting to move beyond their limits. I have heard it’s likely a timing issue, but I’m not sure how to fix it. Is there anything obvious in my code that may be causing it? It’s very basic, but this is more for an introductory exercise.

For the record, the motors are already installed in a robotic arm rig.

#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

int DefPos1, DefPos2;

int potpin1 = 0;
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int potpin5 = 4;
int potpin6 = 5;

int val1;
int val2;
int val3;
int val4;
int val5;
int val6;


void setup() {
 servo1.attach(2);
 servo2.attach(3);
 servo3.attach(4);
 servo4.attach(5);
 servo5.attach(6);
 servo6.attach(7);

 servo1.write(130); // Place default positions
 servo2.write(90);
 servo3.write(70);
 servo4.write(50);
 servo5.write(80);
 servo6.write(110);
}


void loop() {

 val1 = analogRead(potpin1);
 val1 = map(val1, 80, 1024, 0, 180);
 servo1.write(val1);

 val2 = analogRead(potpin2);
 val2 = map(val2, 20, 1024, 0, 150);
 servo2.write(val2);

 val3 = analogRead(potpin3);
 val3 = map(val3, 20, 1024, 0, 120);
 servo3.write(val3);

 val4 = analogRead(potpin4);
 val4 = map(val4, 20, 1024, 0, 90);
 servo4.write(val4);

 val5 = analogRead(potpin5);
 val5 = map(val5, 10, 1024, 0, 170);
 servo5.write(val5);

 val6 = analogRead(potpin6);
 val6 = map(val6, 50, 1024, 0, 120);
 servo6.write(val6);

 delay(50);
}

How are the servos powered ?

The servos are powered externally from a five volt power supply in parallel. The pots will be run from the mega's own power.

I'm almost complete, but recently I've been getting a great deal of dithering and multiple motors attempting to move beyond their limits. I have heard it's likely a timing issue, but I'm not sure how to fix it.

Do you have the external power supply ground and a the mega ground connected together? Disconnect all servos except one that has been stuttering and see if it still stutters. Servos under load like in robotic arms and such take a lot of power. What is the voltage of the external power supply when the servos are stuttering?