#include <Servo.h>
Servo myservo;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
int potpin = 0;
int val;
void setup() {
myservo.attach(9);
pinMode(A0, INPUT);
Serial.begin(9600);
lcd.init();
}
void loop() {
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
myservo.write(val);
delay(15);
int potensio = analogRead(A0);
float tegP = potensio*(5.0/1024.0);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Tegangan Potensio = ");
lcd.println(tegP);
lcd.setCursor(0, 1);
lcd.print("Nilai ADC = ");
lcd.println(potensio);
lcd.scrollDisplayLeft();
delay(200);
}