#include <LiquidCrystal_I2C.h>
#define numAdress 0X27
#define numColum 16
#define numLine 2
int pressedButton = 0;
const int buttonPins[] = { 5, 4, 3, 2, 1 };
LiquidCrystal_I2C lcd(numAdress, numColum, numLine);
void setup() {
Serial.begin(9600);
for (uint8_t i = 1; i <= 5; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
lcd.init();
lcd.backlight();
delay(1000);
lcd.setCursor(4,0);
lcd.print("LCD menu");
lcd.setCursor(5,1);
lcd.print("V0.0.1");
delay(2000);
lcd.clear();
}
void loop() {
for (int i = 1; i <= 5; i++) {
if (digitalRead(buttonPins[i]) == LOW) {
pressedButton = i;
}
}
Serial.println(pressedButton);
}