#include <Arduino.h>
#include <ESP32Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int potPin = 34;
int servoPin = 32;
int angle = 0;
Servo myservo;
void setup() {
Serial.begin(115200);
lcd.init();
lcd.backlight();
pinMode(potPin, INPUT);
myservo.attach(servoPin);
}
void loop() {
int potValue = analogRead(potPin);
float angle = (potValue / 4095.0) * 180;
float percentage = (angle / 180) * 100;
myservo.write(angle);
int brightness = (potValue / 4095.0) * 255;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Potensiometer:");
lcd.setCursor(0, 1);
lcd.print(potValue);
Serial.print("Nilai Potensiometer: ");
Serial.println(potValue);
delay(1000);
}