#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int buttonPins[4] = {2, 3, 4, 5};
const int potPins[4] = {A0, A1, A2, A3};
void setup() {
Wire.begin();
lcd.begin(16, 2);
lcd.backlight();
for (int i = 0; i < 4; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
lcd.setCursor(0, 0);
lcd.print("HMI Ready");
delay(2000);
lcd.clear();
}
void loop() {
for (int i = 0; i < 4; i++) {
if (digitalRead(buttonPins[i]) == LOW) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Pot ");
lcd.print(i + 1);
lcd.print(" Value:");
int potValue = analogRead(potPins[i]);
float voltage = (potValue / 1023.0) * 5;
lcd.setCursor(0, 1);
lcd.print(voltage, 2);
lcd.print(" V");
delay(500);
}
}
}