Hello everyone,
my name is Senna and i got a project where 2 servo motors need to turn on the exact same speed.
The servos are continuous. The problem is that 1 turns faster than the other one.
They don't have a potentiometer.
#include <Servo.h>
Servo servo_L;
Servo servo_R;
int buttonState1 = 0;
int buttonState2 = 0;
int pos= 1500;
int var1=0;
int var2=0;
void setup(){
Serial.begin(115200);
// servo_L.attach(5); //Left servo Pin3
// servo_R.attach(6); //Right servo Pin3
pinMode(3, INPUT); //Button 1
pinMode(4, INPUT); //Button 2
}
void loop(){
buttonState1 = digitalRead(3);
buttonState2 = digitalRead(4);
if (buttonState1 == 1) {
servo_L.attach(5); //Left servo Pin3
servo_R.attach(6); //Right servo Pin3
servo_L.writeMicroseconds(2000); // tell servo's to go to position in variable 'pos'
servo_R.writeMicroseconds(2000);
Serial.println("Button 1, turning");
delay(25);
}
else if (buttonState1== 0){
servo_L.detach();
servo_R.detach();
// servo_L.writeMicroseconds(1500); // tell servo's to go to position in variable 'pos'
// servo_R.writeMicroseconds(1500);
}
if (buttonState2 == 1) {
servo_L.attach(5); //Left servo Pin3
servo_R.attach(6); //Right servo Pin3
servo_L.writeMicroseconds(600); // tell servo's to go to position in variable 'pos'
servo_R.writeMicroseconds(600);
Serial.println("Button 2, turning in steps");
delay(2000);
}
if (buttonState2== 0){
servo_L.detach();
servo_R.detach();
// servo_L.writeMicroseconds(1500); // tell servo's to go to position in variable 'pos'
// servo_R.writeMicroseconds(1500);
}
}
This is my code. I tried fine-tuning via software but couldn't get them to turn the exact same speed.
Maybe someone can tell me what the problem is, and how to fix it.
Can't wait to read the reply's.
Kind regards,
Senna Nieuwland