Hi all, im just looking for a little guidance. I have 3d printed a 4 degree of freedom robot arm with 4 servo motors that I am currently trying to program.
my problem is that I only have one joystick, and the current code I am using is only for controlling 2 servo motors, Im wondering how I can adapt this code to click the joystick button and it switch control to servo motors 3&4(joyX2 and joyY2) instead of 1&2.(joyX1 and joyY1)
If someone could point me in the right direction to a video or has a quick minute to explain that would be absolutely amazing.
Here is the code;
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;int joyX1 = A0;
int joyY1 = A1;int joyX2 = A0;
int joyY2 = A1;int servoVal;
void setup() {
servo1.attach(6);
servo2.attach(9);
servo3.attach(10);
servo4.attach(11);
}void loop() {
servoVal = analogRead(joyX1) ;
servoVal = map(servoVal, 0, 1023, 0, 180);
servo1.write(servoVal); servoVal = analogRead(joyX1);servoVal = analogRead(joyY1);
servoVal = map(servoVal, 0, 1023, 0, 180);
servo1.write(servoVal); servoVal = analogRead(joyY1);servoVal = analogRead(joyX2) ;
servoVal = map(servoVal, 0, 1023, 0, 180);
servo1.write(servoVal); servoVal = analogRead(joyX2);servoVal = analogRead(joyY2);
servoVal = map(servoVal, 0, 1023, 0, 180);
servo1.write(servoVal); servoVal = analogRead(joyY2);