Skip to content

Instantly share code, notes, and snippets.

@ednisley
Created May 3, 2017 14:44
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 ednisley/0a1cdfb27babf5a5217f568d5bc68a2d to your computer and use it in GitHub Desktop.
Save ednisley/0a1cdfb27babf5a5217f568d5bc68a2d to your computer and use it in GitHub Desktop.
Arduino source code: resistive joystick exercise
// Joystick exercise
#define JOYX A0
#define JOYY A1
#define BUTTON 7
int JoyX,JoyY;
boolean Button;
//-- Helper routine for printf()
int s_putc(char c, FILE *t) {
Serial.write(c);
}
void setup() {
Serial.begin (9600);
fdevopen(&s_putc,0); // set up serial output for printf()
Serial.println ("Joystick exercise");
Serial.println ("Ed Nisley - KE4ZNU - May 2017");
pinMode(BUTTON,INPUT_PULLUP);
}
void loop() {
JoyX = analogRead(JOYX);
delay(100);
JoyY = analogRead(JOYY);
delay(100);
Button = digitalRead(BUTTON);
printf("%05d - %05d - %1d\r",JoyX,JoyY,Button);
}
@ednisley
Copy link
Author

ednisley commented May 3, 2017

More details on my blog at http://wp.me/poZKh-6J1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment