/**
* Source code:
* https://www.italiantechproject.it/tutorial-arduino/joystick
*/
#define JOYSTICK_X A0
#define JOYSTICK_Y A1
#define JOYSTICK_BUTTON 2
void setup(){
Serial.begin(9600);
pinMode(JOYSTICK_BUTTON, INPUT_PULLUP);
}
void loop(){
int x = analogRead(JOYSTICK_X);
int y = analogRead(JOYSTICK_Y);
int button = !digitalRead(JOYSTICK_BUTTON);
Serial.print("X: " + String(x));
Serial.print(",\tY:" + String(y));
Serial.println(",\tP: " + String(button));
delay(100);
}