#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD (Assuming 0x27 as the I2C address)
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// Start the LCD
lcd.init();
lcd.backlight();
// Set up the message on the LCD
lcd.setCursor(0, 0);
lcd.print("Potentiometer:");
delay(2000);
lcd.clear();
// Initialize serial communication (optional for debugging)
Serial.begin(9600);
}
void loop() {
// Read the analog value from the potentiometer
int potValue = analogRead(A0);
// Print the value on the Serial Monitor (for debugging)
Serial.print("Potentiometer Value: ");
Serial.println(potValue);
// Display the value on the LCD
lcd.setCursor(0, 0);
lcd.print("Potentiometer:");
lcd.setCursor(0, 1);
lcd.print("Value: ");
lcd.print(potValue); // Display the potentiometer reading
// Wait for a short while before the next reading
delay(500);
}