// LCD pins details: https://docs.wokwi.com/parts/wokwi-lcd1602
// Include the library used to manage the LCD
#include <LiquidCrystal.h>
/*
https://www.arduino.cc/reference/en/libraries/liquidcrystal/
The LiquidCrystal.h Library will use the ESP32 pins as follow to send information to the LCD:
- Pin 13 (RS) to indicate if a Command (LOW) or Data (HIGH) will be received by the LCD.
- Pin 12 (EN) to Enable (activate / HIGH) the LCD to receive Command or Data from the ESP32.
- Pin 25, 26, 27 & 14 to sent the Command or Data to LCD.
*/
// Create An LCD Object. Signals: [ RS, EN, D4, D5, D6, D7 ]
LiquidCrystal My_LCD(13, 12, 25, 26, 27, 14);
/*
https://maxpromer.github.io/LCD-Character-Creator/
Define the variable with the symbol of a SPEAKER to be displayed on the LCD using LiquidCrystal.h library
*/
byte SpeakerChar[] = {
B00001, // ☐☐☐☐◼︎
B00011, // ☐☐☐◼︎◼︎
B00111, // ☐☐◼︎◼︎◼︎
B11111, // ◼︎◼︎◼︎◼︎◼︎
B11111, // ◼︎◼︎◼︎◼︎◼︎
B00111, // ☐☐◼︎◼︎◼︎
B00011, // ☐☐☐◼︎◼︎
B00001 // ☐☐☐☐◼︎
};
// Define the variable with the symbol of two ARROWS to be displayed on the LCD using LiquidCrystal.h library
byte flechas[] = {
B00100, // ☐☐◼︎☐☐
B01110, // ☐◼︎◼︎◼︎☐
B11111, // ◼︎◼︎◼︎◼︎◼︎
B00000, // ☐☐☐☐☐
B00000, // ☐☐☐☐☐
B11111, // ◼︎◼︎◼︎◼︎◼︎
B01110, // ☐◼︎◼︎◼︎☐
B00100 // ☐☐◼︎☐☐
};
void setup()
{
// Initialize the LCD with 16 columns and 2 lines
My_LCD.begin(16, 2);
// Assign the custom character number zero to SPEAKER and number one to ARROWS
My_LCD.createChar(0, SpeakerChar);
My_LCD.createChar(1, flechas);
}
void loop()
{
// Clear the LCD of any previous message
My_LCD.clear();
// Display the first message in home position (0, 0): column zero and line zero
My_LCD.print("Hello");
// Display the custom SPEAKER symbol just after the "Hello" message
My_LCD.write(byte(0));
// Set the cursor position to column zero of line one of the LCD
My_LCD.setCursor(0, 1);
// Display the custom ARROWS symbol in column zero of line one of the LCD
My_LCD.write(byte(1));
// Display the Kitty message just after the ARROWS symbol
My_LCD.print("Kitty");
// One second delay before displaying the message again
delay(1000);
}