#include <Servo.h>
int xValue = 0;
int yValue = 0;
Servo xServo; // create servo object to control the X servo
Servo yServo; // create servo object to control the Y servo
void setup(){
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(7, INPUT_PULLUP);
xServo.attach(9); // attaches the servo on pin 9
yServo.attach(10); // attaches the servo on pin 10
}
void loop(){
xValue = analogRead(A0);
int xAngle = map(xValue, 0, 1023, 0, 180); // map analog input to servo angle
xServo.write(xAngle); // set the X servo position
Serial.print("X:");
Serial.print(xValue, DEC);
yValue = analogRead(A1);
int yAngle = map(yValue, 0, 1023, 0, 180); // map analog input to servo angle
yServo.write(yAngle); // set the Y servo position
Serial.print(" | Y:");
Serial.print(yValue, DEC);
int buttonState = digitalRead(7);
Serial.print(" | Button:");
Serial.println(buttonState, DEC);
delay(100);
}