Hello i have been working on a hexapod for my A-level DT project and i am having trouble with my servos at first they all worked fine but as i added more they started to occasionally move to random directions when i connected the arduino to them i have tried connecting more current to them(currently i am using 6 4xAA battery packs in parallel) but this was ineffective i think it is a problem with the cleanliness of the power so i'm going to try connecting capacitors to each servos but i was wondering if you have a had a similar problem and know how to fix it? here is my code but i'm fairly sure its not a problem with that and if you need i will upload pictures of the bot itself
(STS=Side to side)(UAD=up and down)(foot=ankle control)
#include <Servo.h>
Servo STS1;
Servo STS2;
Servo STS3;
Servo STS4;
Servo STS5;
Servo STS6;
Servo FOOT1;
Servo FOOT2;
Servo FOOT3;
Servo FOOT4;
Servo FOOT5;
Servo UAD1;
Servo UAD2;
Servo UAD3;
Servo UAD4;
Servo UAD5;
Servo UAD6;
void setup()
{
STS1.attach(10); // servo on digital pin 10
STS2.attach(3);
STS3.attach(A1);
STS4.attach(8);
STS5.attach(4);
STS6.attach(A3);
FOOT1.attach(11);
FOOT2.attach(9);
FOOT3.attach(A0);
FOOT4.attach(13);
FOOT5.attach(A2);
UAD1.attach(6);
UAD2.attach(2);
UAD3.attach(5);
UAD4.attach(12);
UAD5.attach(7);
UAD6.attach(A4);
}
void loop()
{
STS1.write(30);
STS2.write(30);
STS3.write(90);
STS4.write(60);
STS5.write(60);
STS6.write(90);
FOOT1.write(110);
FOOT4.write(100);
FOOT5.write(140);
UAD1.write(50);
UAD4.write(85);
UAD5.write(85);
delay(1000);
UAD1.write(90);
UAD4.write(50);
UAD5.write(50);
FOOT1.write(140);
FOOT4.write(70);
FOOT5.write(70);
delay(1000);
STS1.write(80);
STS4.write(5);
STS5.write(5);
delay(1000);
STS1.write(80);
STS4.write(5);
STS5.write(5);
FOOT1.write(110);
FOOT4.write(110);
FOOT5.write(130);
UAD1.write(50);
UAD4.write(100);
UAD5.write(100);
delay(1000);
STS1.write(60);
STS4.write(25);
STS5.write(25);
STS2.write(0);
STS6.write(110);
STS3.write(60);
FOOT2.write(150);
FOOT3.write(150);
UAD2.write(50);
UAD3.write(50);
UAD6.write(50);
delay(1000);
UAD2.write(90);
UAD3.write(90);
UAD6.write(90);
FOOT2.write(180);
FOOT3.write(180);
delay(1000);
STS2.write(50);
STS6.write(60 );
STS3.write(110);
delay(1000);
STS2.write(50);
STS3.write(110);
FOOT2.write(150);
FOOT3.write(150);
UAD2.write(50);
UAD3.write(50);
UAD6.write(50);
delay(1000);
}