// LCD pins details: https://docs.wokwi.com/parts/wokwi-lcd1602
// Includes the library to allow the I2C communication from the micro to the LCD
#include <Wire.h> // https://www.arduino.cc/reference/en/language/functions/communication/wire/
// Includes the library used to manage the LCD through I2C (Inter-Integrated Circuit) communication protocol
#include <LiquidCrystal_I2C.h>
/*
https://www.arduino.cc/reference/en/libraries/liquidcrystal-i2c/
The LiquidCrystal_I2C.h Library configures the pin D22 of ESP32 as SDA (Serial DAta lne) to send the data to the LCD,
while pin D21 is configured as SCL (Serial CLock line) to sinchronize the serial data transmission between ESP32 & LCD.
https://youtu.be/CAvawEcxoPU
*/
LiquidCrystal_I2C I2C_LCD1(0x27, 16, 2); // set the LCD address as the device 0x27 (0100 111) with a 16 chars and 2 line display
void setup()
{
// Initialize I2C communication with the LCD
I2C_LCD1.init();
// Turn ON the backlight of the LCD
I2C_LCD1.backlight();
}
void loop()
{
// Clear the LCD of any previous message
I2C_LCD1.clear();
// Display the first message in the first line of the LCD
I2C_LCD1.print("Hello");
// Set the cursor position to column zero of line one of the LCD
I2C_LCD1.setCursor(0,1);
// Display the Kitty message starting in column zero of line one of the LCD
I2C_LCD1.print("Kitty");
// One second delay before displaying the message again
delay(1000);
}