Skip to content

Instantly share code, notes, and snippets.

@xslendix
Created April 22, 2018 18:19
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 xslendix/213ad9bb21faf9968b1388b1e29c2629 to your computer and use it in GitHub Desktop.
Save xslendix/213ad9bb21faf9968b1388b1e29c2629 to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int buttonState = 0;
int program = 1;
int programs = 1;
int a = 1;
byte man_1[8] = {
0x01,
0x05,
0x0E,
0x14,
0x14,
0x04,
0x0A,
0x0A
};
byte man_2[] = {
0x02,
0x05,
0x0E,
0x14,
0x14,
0x04,
0x0A,
0x0A
};
void setup() {
pinMode(2, INPUT);
Serial.begin(9600);
lcd.begin();
lcd.createChar(1, man_1);
lcd.createChar(2, man_2);
lcd.home();
lcd.backlight();
}
void loop() {
buttonState = digitalRead(2);
if (buttonState == HIGH) {
if (program > programs) {
program = 1;
} else {
program++;
}
}
switch (program){
case 1:
if (a == 1) {
a = 2;
lcd.print("Hello, world! ");
lcd.write(2);
} else {
a = 1;
lcd.print("Hello, world! ");
lcd.write(1);
}
delay(600);
lcd.clear();
default:
Serial.print("");
}
lcd.setCursor(0,1);
lcd.print("Program nr: ");
lcd.print(program);
lcd.print("/");
lcd.print(programs);
lcd.setCursor(0,0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment