// 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);
// Definir nombre de pins
#define PinAnalogo 35 //Pin de ESP32 donde se lee el voltaje analógico
//Declarar variables
int ValorDigital; // Variable que obtendrá el valor digital después de la conversión
void setup()
{
// Initialize the LCD with 16 columns and 2 lines
My_LCD.begin(16, 2);
// Establecer resolución de 12 bits (0-4095 -> 4096), 10 bits (0-1023 -> 1024), 8 bits (0-255 -> 256)
analogReadResolution(10);
}
void loop()
{
// Leer el valor de voltaje en el PinAnalogo
ValorDigital = analogRead(PinAnalogo);
// 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");
// Set the cursor position to column zero of line one of the LCD
My_LCD.setCursor(0, 1);
// Display the Kitty message just after the ARROWS symbol
My_LCD.print("Kitty ");
// Display variable
My_LCD.print(ValorDigital);
// One second delay before displaying the message again
delay(500);
}