#include <LiquidCrystal.h>
LiquidCrystal lcd(18, 5, 17, 16, 4, 0);
int buttonPins[5] = {12, 14, 27, 26, 25};
int count_1 = 0;
int count_2 = 0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
for (int i = 0; i < 5; i++)
{
pinMode(buttonPins[i], INPUT_PULLUP);
}
}
void loop() {
delay(1000);
if (digitalRead(buttonPins[0]) == 0)
{ lcd.clear();
count_1 = count_1 + 1;
lcd.setCursor(0, 0);
lcd.print("Count 1 : " + String(count_1));
}
else if (digitalRead(buttonPins[1]) == 0)
{
lcd.clear();
count_1 = count_1 - 1;
lcd.setCursor(0, 0);
lcd.print("Count 1 : " + String(count_1));
}
else if (digitalRead(buttonPins[2]) == 0)
{
lcd.clear();
count_2 = count_2 + 1;
lcd.setCursor(0, 0);
lcd.print("Count 2 : " + String(count_2));
}
else if (digitalRead(buttonPins[3]) == 0)
{ lcd.clear();
count_2 = count_2 - 1;
lcd.setCursor(0, 1);
lcd.print("Count 2 : " + String(count_2));
}
else if (digitalRead(buttonPins[4]) == 0)
{ lcd.clear();
count_1 = 0;
count_2 = 0;
lcd.setCursor(0, 0);
lcd.print("Count 1 : " + String(count_1));
lcd.setCursor(0, 1);
lcd.print("Count 2 : " + String(count_2));
}
}