Created
November 26, 2019 12:58
-
-
Save RobolinkAkademi/65b7eafac125ce9759194bbee51a3133 to your computer and use it in GitHub Desktop.
arduino xy joystick example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define JoyX A0 | |
#define JoyY A1 | |
#define JoyBut 2 | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(JoyX, INPUT); | |
pinMode(JoyY, INPUT); | |
pinMode(JoyBut, INPUT_PULLUP); | |
} | |
void loop() | |
{ | |
int joy_x = analogRead(JoyX); | |
int joy_y = analogRead(JoyY); | |
int buton = digitalRead(JoyBut); | |
Serial.print("joy_x = "); | |
Serial.print(joy_x ); | |
Serial.print(" joy_y = "); | |
Serial.print(joy_y ); | |
Serial.print(" button = "); | |
Serial.println(!buton); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment