This is the get started example demonstrating how to create a menu of two screens with dynamically changing information.
#include <LiquidCrystal.h>
const byte LCD_RS = 12;
const byte LCD_E = 11;
const byte LCD_D4 = 5;
const byte LCD_D5 = 4;
const byte LCD_D6 = 3;
const byte LCD_D7 = 2;
LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
const byte analogPin = A1;
unsigned short analogReading = 0;
unsigned short lastAnalogReading = 0;
unsigned int period_check = 1000;
unsigned long lastMs_check = 0;
unsigned int period_nextScreen = 5000;
unsigned long lastMs_nextScreen = 0;
LiquidLine analogReading_line(0, 0,
"Analog: ", analogReading);
void setup() {
Serial.begin(250000);
pinMode(analogPin, INPUT);
lcd.begin(16, 2);
menu.add_screen(welcome_screen);
menu.add_screen(secondary_screen);
}
void loop() {
if (millis() - lastMs_check > period_check) {
lastMs_check = millis();
analogReading = analogRead(analogPin);
if (analogReading != lastAnalogReading) {
lastAnalogReading = analogReading;
menu.update();
}
}
if (millis() - lastMs_nextScreen > period_nextScreen) {
lastMs_nextScreen = millis();
menu.next_screen();
}
}