#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define POT_PIN 34 // Pin untuk SIG potensiometer
LiquidCrystal_I2C lcd(0x27, 16, 2); // Alamat I2C LCD 16x2 adalah 0x27
void setup() {
lcd.init(); // Inisialisasi LCD
lcd.backlight(); // Nyalakan lampu latar LCD
pinMode(POT_PIN, INPUT); // Set pin potensiometer sebagai input
}
void loop() {
int sensorValue = analogRead(POT_PIN); // Baca nilai dari potensiometer
float pHValue = map(sensorValue, 0, 4095, 0, 14); // Konversi nilai ADC ke pH (0-14)
// Tampilkan nilai pH pada LCD
lcd.clear(); // Hapus layar LCD
lcd.setCursor(0, 0);
lcd.print("pH Value: ");
lcd.print(pHValue, 1); // Tampilkan nilai pH dengan 1 desimal
// Tentukan kategori pH
lcd.setCursor(0, 1);
if (pHValue <= 6) {
lcd.print("Asam");
} else if (pHValue == 7) {
lcd.print("Netral");
} else {
lcd.print("Basa");
}
delay(500); // Delay 500 ms sebelum pembacaan berikutnya
}