#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Alamat I2C LCD, sesuaikan dengan alamat LCD yang Anda gunakan
int potValue = 0; // Variabel untuk menyimpan nilai potensiometer
int percentage = 0;
void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
// put your main code here, to run repeatedly:
int a = analogRead(A0);
int pwm = map(a,0,1023,0,100);
analogWrite(3, pwm);
analogWrite(4, pwm);
analogWrite(5, pwm);
lcd.setCursor(0, 1);
lcd.print("Percentage: ");
lcd.print(pwm);
lcd.print("%");
delay(500); // Tunda agar nilai tidak berubah terlalu cepat
lcd.clear(); // Hapus tampilan sebelumnya
Serial.print("Value Analog = ");
Serial.println(a);
Serial.print("Value PWM = ");
Serial.println(pwm);
delay(250);
}