#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the ESP32 pin number it is connected to
const int rs = 14, en = 27, d4 = 26, d5 = 25, d6 = 33, d7 = 32;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// define the pin used to read the potentiometer value
const int potPin = A0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Clear the display of the LCD.
lcd.clear();
// Display a message on the LCD
lcd.setCursor(0, 0);
lcd.print("Potentiometer");
lcd.setCursor(0, 1);
lcd.print("Value:");
// start serial communication
Serial.begin(9600);
}
void loop() {
// read the value of the potentiometer
int potValue = analogRead(potPin);
// display the potentiometer value on the LCD
lcd.setCursor(7, 1);
lcd.print(potValue);
// print the potentiometer value to the serial monitor
Serial.print("Potentiometer value: ");
Serial.println(potValue);
delay(100); // wait a bit before reading the potentiometer again
}