Skip to content

Instantly share code, notes, and snippets.

@futoase
Last active December 30, 2015 19:29
Show Gist options
  • Select an option

  • Save futoase/7874321 to your computer and use it in GitHub Desktop.

Select an option

Save futoase/7874321 to your computer and use it in GitHub Desktop.
#include <LiquidCrystal.h>
LiquidCrystal g_lcd( 12, 11, 5, 4, 3, 2 ); // rs, enable, d4, d5, d6, d7
void setup()
{
pinMode(9, INPUT);
pinMode(8, INPUT);
pinMode(7, OUTPUT);
g_lcd.begin( 16, 2 );
g_lcd.clear();
}
int my = 0;
void loop()
{
g_lcd.setCursor( 0, 1 );
for (int i = 0; i < my; i++) {
g_lcd.print(" ");
}
g_lcd.print("A");
for (int i = my; i < 15; i++) {
g_lcd.print(" ");
}
if (digitalRead(9) == HIGH) {
if (my > 0) { my -= 1; }
g_lcd.setCursor( 0, 0 );
g_lcd.print(" <<- ");
tone(7, 262, 100);
}
else if (digitalRead(8) == HIGH) {
if (my < 15) { my += 1; }
tone(7, 523, 100);
g_lcd.setCursor( 0, 0 );
g_lcd.print(" ->> ");
}
else {
//g_lcd.clear();
}
delay( 100 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment