Ive only just started learning arduino and Im trying to use one joystick with only the x axis to control two servo motors, but I need one of them to go clockwise and the other to go anticlockwise. Is there any way I can do this? Here is my code so far.
#include <Servo.h>
Servo servo1;
Servo servo2;
int joyX = 0;
int joyY = 1;
int joyVal;
void setup()
{
servo1.attach(1);
servo2.attach(2);
}
void loop()
{
joyVal = analogRead(joyX);
joyVal = map(joyVal, 0, 1023, 0, 180);
servo1.write(joyVal);
joyVal = analogRead(joyX);
joyVal = map(joyVal, 0, 1023, 0, 180);
servo2.write(joyVal);
delay(15);
}