Go Down

Topic: 2 motors controlled by one joystick (Read 42123 times) previous topic - next topic

micahfriesen

I know that this is an old forum, but for future reference,
Code: [Select]

#include <Servo.h>
Servo myServo1;
Servo myServo2;
int lXPin = A0;
int lYPin = A1;
int lX;
int lY;
int l;
int r;
void setup() {
  myServo1.attach(3);
  myServo2.attach(4);
}
void loop() {
  lX = analogRead(lXPin);
  lY = analogRead(lYPin);
  l = lX + lY - 90;
  r = lX - lY + 90;
  myServo1.write(r);
  myServo2.write(l);
}

Go Up