Skip to content

Instantly share code, notes, and snippets.

@RobolinkAkademi
Created November 26, 2019 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobolinkAkademi/65b7eafac125ce9759194bbee51a3133 to your computer and use it in GitHub Desktop.
Save RobolinkAkademi/65b7eafac125ce9759194bbee51a3133 to your computer and use it in GitHub Desktop.
arduino xy joystick example
#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