#include <LiquidCrystal_I2C.h>
#define BTN1 3
#define BTN2 4
LiquidCrystal_I2C lcd(0x27, 16,2);
int pushCounter = 0;
void setup() {
lcd.init();
lcd.backlight();
pinMode(BTN1, INPUT_PULLUP);
pinMode(BTN2, INPUT_PULLUP);
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("Count: ");
lcd.setCursor(0, 1);
lcd.print(pushCounter);
if(digitalRead(BTN1) == LOW) {
delay(100);
lcd.clear();
pushCounter = pushCounter + 1;
}
if(digitalRead(BTN2) == LOW) {
delay(100);
lcd.clear();
pushCounter = pushCounter - 1;
}
}