Hello guys, I am working on a quadruped project with 8 servos and whenever I try to run more than 3-4 servos every servo in the system jumps to the maximum position and stops there. Even I readjust one manually it jumps to max pos again. Only way to fix it is remove all servos from the breadboard and relink them and it happens again if i run more than 3-4. Could this be a battery problem? I use 4 AA batteries (6v total), this issue started after i used the servolibrary with slowmove. Can batteries be depleted so quickly? (I didnt run more than 5-6 and total running time is like 30-40 minutes, could that deplete the 4 batteries?)
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
#include <VarSpeedServo.h>
VarSpeedServo myservo1;
VarSpeedServo myservo2;
VarSpeedServo myservo3;
VarSpeedServo myservo4;
VarSpeedServo myservo5;
VarSpeedServo myservo6;
VarSpeedServo myservo7;
VarSpeedServo myservo8;
unsigned long leg1timer;
unsigned long leg2timer;
unsigned long leg3timer;
unsigned long leg4timer;
void setup()
{
myservo1.attach(2);
myservo2.attach(3);
myservo3.attach(4);
myservo4.attach(5);
myservo5.attach(6);
myservo6.attach(7);
myservo7.attach(8);
myservo8.attach(9); // attaches the servo on pin 9 to the servo object
leg1timer=millis();
leg2timer=millis();
leg3timer=millis();
leg4timer=millis();
}
void leg1forward()
{
leg1timer = millis ();
myservo2.write(80);
myservo1.slowmove(120,60);
delay(600);
myservo2.write(60);
myservo1.slowmove(40,20);
}
void leg2forward()
{
leg2timer = millis ();
myservo4.write(80);
myservo3.slowmove(40,60);
delay(600);
myservo4.write(60);
myservo3.slowmove(120,20);
}
void leg3forward()
{
leg3timer = millis ();
myservo6.write(80);
myservo5.slowmove(20,60);
delay(600);
myservo6.write(60);
myservo5.slowmove(100,20);
}
void leg4forward()
{
leg4timer = millis ();
myservo8.write(80);
myservo7.slowmove(100,60);
delay(600);
myservo8.write(80);
myservo7.slowmove(20,20);
}
void loop()
{
if ( (millis () - leg1timer) >= 2000)
leg1forward();
if ( (millis () - leg3timer) >= 2000)
leg3forward();
if ( (millis () - leg2timer) >= 2000)
leg2forward();
if ( (millis () - leg4timer) >= 2000)
leg4forward();
}
This is the code I use