//includes the LCD library
#include <LiquidCrystal.h>
/* LCD RS - pin 7
* LCD Enable - pinl 6
* LCD D4 - pin 5
* LCD D5 - pin 4
* LCD D6 - pin 3
* LCD D7 - pin 2
The 7-th pin of the LCD is connected to the display brightness
control potentiometer! */
// Init the LCD with the stated pin numbers
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const byte HOURGLASS_TOP[8] = {
0b11111,
0b11111,
0b01110,
0b00100,
0b01010,
0b10001,
0b11111,
0b00000
};
const byte HOURGLASS_MIDDLE[8] = {
0b11111,
0b10001,
0b01110,
0b00100,
0b01110,
0b10001,
0b11111,
0b00000
};
const byte HOURGLASS_BOTTOM[8] = {
0b11111,
0b10001,
0b01010,
0b00100,
0b01110,
0b11111,
0b11111,
0b00000
};
byte currentImage = 0;
void setup() {
// Load custom characters of the hourglass
lcd.createChar(0, HOURGLASS_TOP);
lcd.createChar(1, HOURGLASS_MIDDLE);
lcd.createChar(2, HOURGLASS_BOTTOM);
// Sets the no. of rows and columns of the LCD
lcd.begin(16, 2);
}
void loop() {
lcd.setCursor(0,0);
lcd.write(currentImage);
if (currentImage == 2) {
currentImage = 0;
} else {
currentImage++;
}
delay(1000);
}