I am making a waffle machine and for this I need to run two heavy duty RC servos in opposite direction. The problem is how to sync them so they lift together. They will obviously have different neutral point, currently I am using a digital level and running just one servo at the time to find out when my waffle iron is level. one servo is barely strong enough to lift iron when I took of some parts. If this is a good approach then what will be the code? My problem is how to get the servos to move smoothly together i.e in sync and in opposite direction. I want the whole sweep i.e 75 deg to happen in 4s:
/*
waffle maker.
*/
// include the Servo library
#include <Servo.h>
Servo myServo1; // create a servo object
Servo myServo2; // create a servo object
int angle; // variable to hold the angle for the servo motor
int pos=0;
int servo1Neutral=36; //manually calibrated
int servo2Neutral=24; //manually calibrated
int moveMents2Open= 75; // it basically just goes up to open
int moveMents2Close= 0; // can be tuned to get it to closely properly
int time2Open= 4; // seconds to open the thing
void setup() {
myServo1.attach(9); // attaches the servo on pin 9 to the servo object
myServo2.attach(8); // attaches the servo on pin 9 to the servo object
Serial.begin(9600); // open a serial connection to your computer
Serial.print("go to neutral");
myServo1.write(servo1Neutral);
myServo1.write(servo1Neutral);
delay(10000);
}
void loop() {
angle=45; // should hold actual position
// print out the angle for the servo motor
Serial.print("Angle: ");
Serial.println(angle);
for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myServo1.write(pos);
myServo2.write(pos); // tell servo to go to position in variable 'pos'
delay(30); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=0; pos-=1) // goes from 180 degrees to 0 degrees
{
myServo1.write(pos); // tell servo to go to position in variable 'pos'
myServo2.write(pos);
delay(30); // waits 15ms for the servo to reach the position
}
}