controlar 5 servos con potenciometros

La cosa es que tengo 16 años y estoy empezando con esto... he intentado hacer un código para una mano articulada que funciona con 5 servos (cadauno controla un dedo) y cada servo se regula con un potenciometro. El problema es que al conectar los servos y los potenciometros y encenderlo todo, los servos se mueven solos de un lado para otro sin ningun tipo de control....
Muchas gracias de antemano.

#include <Servo.h>

Servo myservo;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;// create servo object to control a servo

int potpi = 0;
int pot = 1;
int potp = 2;
int po = 3;
int p = 4;// analog pin used to connect the potentiometer

int val;    // variable to read the value from the analog pin
int val1;
int val2;
int val3;
int val4;


void setup() {
  myservo.attach(9);
  servo2.attach(8);
  servo3.attach(7);
  servo4.attach(6);
  servo5.attach(5);// attaches the servo on pin 9 to the servo object
  
}

void loop() {
  val = analogRead(potpi);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there


    val1 = analogRead(pot);            // reads the value of the potentiometer (value between 0 and 1023)
  val1 = map(val1, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo2.write(val1);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there


    val2 = analogRead(potp);            // reads the value of the potentiometer (value between 0 and 1023)
  val2 = map(val2, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo3.write(val2);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

    val3 = analogRead(po);            // reads the value of the potentiometer (value between 0 and 1023)
  val3 = map(val3, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo4.write(val3);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

    val4 = analogRead(p);            // reads the value of the potentiometer (value between 0 and 1023)
  val4 = map(val4, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo5.write(val4);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}

Bueno un par de recomendaciones sobre como presentar la pregunta. Lee las normas del foro que te indico en el msg privado.

El problema es que al conectar los servos y los potenciometros y encenderlo todo, los servos se mueven solos de un lado para otro sin ningun tipo de control....

Alimenta los servos con una fuete externa (no los 5V del arduino), comparte GND con la fuente externa y no cambies nada mas. Funcionará sin problemas.
La fuente debe ser de la tensión del servo (5V o no mas de 6V) y de la corriente apropiada.