Today we’ll take a look at how to use a joystick with an Arduino to control a pan and tilt Servo platform.
Check us out on Facebook!
ARDUINO Code:
#include <Servo.h>
Servo servoX;
Servo servoY;
int valX;
int valY;
void setup() {
servoX.attach(3);
servoY.attach(5);
}
void loop() {
valX = analogRead(A1);
valX = map(valX, 0, 1023, 0, 180);
servoX.write(valX);
delay(25);
valY = analogRead(A2);
valY = map(valY, 0, 1023, 0, 180);
servoY.write(valY);
delay(25);
}