Stupid question im sure.
I have some code and I have 4 servo I want the axes of myservo3 and servo4 to move in the opposite direction from myservo1 and 2. Im not sure what to do please help.
#include <Servo.h>
//Servo objects created to control the servos
Servo myServo1;
Servo myServo2;
Servo myServo3;
Servo myServo4;
int servo1 = 3; //Digital PWM pin used by the servo 1
int servo2 = 5; //Digital PWM pin used by the servo 2
int servo3 = 6; //Digital PWM pin used by the servo 3
int servo4 = 9; //Digital PWM pin used by the servo 4
int joyX = 0; //Analog pin to which the joystick (X) is connected
int joyY = 1; //Analog pin to which the joystick (Y) is connected
void setup(){
myServo1.attach(servo1);
myServo2.attach(servo2);
myServo3.attach(servo3);
myServo4.attach(servo4);
}
void loop(){
int valX = analogRead(joyX); //Read the joystick X value (value between 0 and 1023)
int valY = analogRead(joyY); //Read the joystick Y value (value between 0 and 1023)
valX = map(valX, 0, 1023, 10, 170); //Scale the joystick X value to use it with the servo
valY = map(valY, 0, 1023, 10, 170); //Scale the joystick Y value to use it with the servo
//Sets the servo position according to the scaled values.
myServo1.write(valX);
myServo2.write(valY);
myServo3.write(valX);//These two servos are ment to move in the opposite direction to myservo1 and 2
myServo4.write(valY);
delay(5);
}