Created
March 26, 2015 06:02
-
-
Save buildcircuit/e8d546795ea5bdbfcc8b to your computer and use it in GitHub Desktop.
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
#include <LiquidCrystal.h> | |
// initialize the library with the numbers of the interface pins | |
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); | |
void setup() | |
{ | |
// set up the LCD's number of rows and columns: | |
lcd.begin(16, 2); | |
// Print a message to the LCD. | |
lcd.print("Hello, world!"); | |
} | |
void loop() | |
{ | |
// set the cursor to column 0, line 1 | |
// (note: line 1 is the second row, since counting begins with 0): | |
lcd.setCursor(0, 1); | |
// All the shield buttons (except reset) are connected to pin A0 | |
// through a resistor network so that different analog values | |
// are produced by each button. | |
int a0 = analogRead(0); | |
if (a0 >= 800) | |
{ | |
lcd.print(" "); | |
} | |
else if (a0 < 800 && a0 >= 600) | |
{ | |
lcd.print("Select"); | |
} | |
else if (a0 < 600 && a0 >= 400) | |
{ | |
lcd.print("Left "); | |
} | |
else if (a0 < 400 && a0 >= 200) | |
{ | |
lcd.print("Down "); | |
} | |
else if (a0 < 200 && a0 >= 100) | |
{ | |
lcd.print("Up "); | |
} | |
else | |
{ | |
lcd.print("Right "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment