#include <LiquidCrystal_I2C.h> // LCD library using from https://www.ardumotive.com/i2clcden.html for the i2c LCD library
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 after finding it from serial monitor (see comment above) for a 16 chars and 2 line display
byte celsius[8] = {
0b00111,
0b00101,
0b00111,
0b00000,
0b11100,
0b10000,
0b10000,
0b11100
};
// navigation
int menuItem = 1;
int lastMenuItem = 1;
int itemIndex[4] = {1,2,3,4};
int page = 0;
int frame = 0;
// engin value
bool backlight = true; // scr backlight
bool lightState = true;
int temp = 22; // current val
int humi = 11;
int setTemp = 27; // setting val
int setHumi = 30;
int targetTemp = 0; // target val
int targetHumi = 0;
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setBacklight(true);
lcd.createChar(0, celsius);
}
void loop()
{
drawHome();
delay(5000);
}
void drawHome() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp :"); // 4 characters max
lcd.setCursor(15,0);
lcd.print("hh:mm"); // current time
lcd.setCursor(0,1);
lcd.print("Humi :");
lcd.setCursor(0,2);
lcd.print("Light :");
lcd.setCursor(1,3);
lcd.print("hh:mm"); // ON time set
lcd.setCursor(7,3);
lcd.print("ON");
lcd.setCursor(11,3);
lcd.print("hh:mm"); // OFF time set
lcd.setCursor(17,3);
lcd.print("OFF");
updateHome();
}
void updateHome() {
// Temp update
lcd.setCursor(7,0);
lcd.print(" ");
lcd.setCursor(7,0);
lcd.print(temp);
lcd.print("/");
lcd.print(setTemp);
//lcd.print("C");
lcd.write(0); // c°
// Humi update
lcd.setCursor(7,1);
lcd.print(" ");
lcd.setCursor(7,1);
lcd.print(humi);
lcd.print("/");
lcd.print(setHumi);
lcd.print("%");
// Light state update
lcd.setCursor(8,2);
lcd.print(" ");
lcd.setCursor(8,2);
if (lightState == true) {
lcd.print("ON");
}else{
lcd.print("OFF");
}
}