Can anyone help please? I'm new to code and everything. I have this code for four different servos and I'm needing two of them to be reversed. I need servo 3 and 4 to be reversed or in other words, the mirror image of servo 1 and 2. can someone please help me!
Thank You
Mike
Heres the code:
#include <Servo.h>
Servo servo1; // create servo object to control a servo
Servo servo2; // create servo object to control a servo
Servo servo3; // create servo object to control a servo
Servo servo4; // create servo object to control a servo
int pos1; // angle of servo 1
int pos2; // angle of servo2
int pos3; // angle of servo3
int pos4; // angle of servo4
void setup()
{
servo1.attach(9); // attaches the servo on pin 9 to the servo head object
servo2.attach(10); // attaches the servo on pin 10 to the servo faceplae object
servo3.attach(11); // attaches the servo on pin 11 to the servo faceplate 2
servo4.attach(12); //attaches the servo on pin 12 to the servo head 2
}
void loop()
{
// Scene 1:
for (int i=0; i<45; i += 1) {
pos1 = 90 - i;
pos2 = 90 + (i1);
pos3 = 90 + i;
pos4 = 90 - (i1);
servo1.write(pos1);
servo2.write(pos2);
servo3.write(pos3);
servo4.write(pos4);
delay(15);
}
// Scene 2
for (int i=0; i<60; i += 1) {
pos1 = 170;
pos2 = 180;
pos3 = 170;
pos4 = 180;
servo1.write(pos1);
servo2.write(pos2);
servo3.write(pos3);
servo4.write(pos4);
delay(15);
}
}