#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD (address 0x27, 16 columns x 2 rows)
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int potPin = A0; // Potentiometer connected to analog pin A0
void setup() {
// Start the LCD
lcd.begin(16, 2); // Specify 16 columns and 2 rows
lcd.backlight(); // Turn on the LCD backlight
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Potentiometer:");
}
void loop() {
int potValue = analogRead(potPin); // Read potentiometer value (0-1023)
int angle = map(potValue, 0, 1023, 0, 360); // Map value to 0-360 degrees
lcd.setCursor(0, 1); // Set cursor to the second row
lcd.print("Angle: ");
lcd.print(angle); // Print the angle
lcd.print(" "); // Clear leftover digits
delay(500); // Update every half second
}