I'm having some trouble getting servos to synchronize.
I'm currently building a robot using and Arduino Uno and some servos. For one of the leg joints I am using 2 servos to operate a single joint, and since they are mirrors of each other, I have to send each servo the opposite angle if I want them to move in sync (for example, I'd write one to 180 and the other to 0). I know that I could buy servo reversers, but I don't want to shell out more money than I have to.
Here is the code I wrote to test it:
#include <Servo.h>
Servo frontHip0;
Servo frontHip180;
Servo rearHip0;
Servo rearHip180;
void setup()
{
frontHip0.attach(7);
frontHip180.attach(6);
rearHip0.attach(8);
rearHip180.attach(9);
frontHip0.write(180);
frontHip180.write(0);
rearHip0.write(180);
rearHip180.write(0);
}
void loop()
{
frontHip0.write(0);
frontHip180.write(180);
rearHip0.write(0);
rearHip180.write(180);
delay(2000);
frontHip0.write(180);
frontHip180.write(0);
rearHip0.write(180);
rearHip180.write(0);
delay(2000);
}
The servos frontHip0 and frontHip180 represent the 2 servos that operate the front hip, and the numbers behind them represent the angle at which they will be at the default position. This is the same for rearHip0 and rearHip180.
Now the problem is that each time all the servos move, their movements are not in sync. When rearHip0 and rearHip180 move, one will rearHip180 will being to move about .3 seconds before rearHip0. This doesn't sound like alot, but because the 2 servos need to operate a single leg, the movements need to be identical. I'm having the same problem with frontHip0 and frontHip180.
I'd just like to note that all 4 servos are the same model from the same company.