#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
int i = 0;
unsigned long previousMillis = 0; // will store last time
// constants won't change:
const long interval = 3000; // interval at which to blink (milliseconds)
void setup() {
lcd.init();
lcd.backlight();
lcd.print("Hello World!");
delay(1000);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time
previousMillis = currentMillis;
switch(i) {
case 1:
infoOne();
break;
case 2:
infoTwo();
break;
default:
i = 0;
break;
}
i++;
}
delay(200); // this speeds up the simulation
}
void infoOne() {
lcd.clear();
lcd.print("Vbat: ");
lcd.print("12.4"); //example
lcd.print("V");
lcd.setCursor(0, 1);
lcd.print("Ibat: ");
lcd.print("-500"); //example
lcd.print("mA");
lcd.setCursor(15, 1);
lcd.print("1");
}
void infoTwo() {
lcd.clear();
lcd.print("Vout: ");
lcd.print("12.2"); //example
lcd.print("V");
lcd.setCursor(0, 1);
lcd.print("Iout: ");
lcd.print("480"); //example
lcd.print("mA");
lcd.setCursor(15, 1);
lcd.print("2");
}