Created
May 3, 2017 14:44
-
-
Save ednisley/0a1cdfb27babf5a5217f568d5bc68a2d to your computer and use it in GitHub Desktop.
Arduino source code: resistive joystick exercise
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
// 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More details on my blog at http://wp.me/poZKh-6J1