#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define b1 12//up
#define b2 13//down
int counter = 0;
void setup() {
Serial.begin(115200);
pinMode(b1, INPUT_PULLUP);
pinMode(b2, INPUT_PULLUP);
lcd.init();
lcd.backlight();
lcd.clear();
delay(1000);
}
void loop() {
int up = !digitalRead(b1);
int down = !digitalRead(b2);
switch (up) {
case 1:
counter++;
break;
}
switch (down) {
case 1:
counter--;
break;
}
lcd.setCursor(4, 0);
lcd.print("Counter:");
lcd.setCursor(6, 1);
lcd.print(counter);
delay(200);
}