#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for 16 chars and 2 line display
#define POT_PIN 34
void setup() {
Serial.begin(115200);
lcd.init(); // initialize the LED
lcd.backlight(); // turn on the LCD screen
lcd.setCursor(0, 0);
lcd.print("Potentiometer Val");
lcd.setCursor(0, 1);
lcd.print("Reading...");
delay(2000);
lcd.clear();
}
// first col and zeroth row lcd.serCursor(1,0)
void loop() {
int potValue = analogRead(POT_PIN);
int percentage = map(potValue, 0, 4095, 0, 100);
Serial.print("Potentiometer Value: ");
Serial.println(potValue);
lcd.setCursor(0, 0);
lcd.print("Raw Value: ");
lcd.print(potValue);
lcd.setCursor(0, 1);
lcd.print("Percentage: ");
lcd.print(percentage);
lcd.print(" %");
delay(500);
}