byte buttonPin1 = 12;
byte buttonPin2 = 14;
byte buttonPin3 = 27;
byte buttonPin4 = 26;
byte buttonPin5 = 25;
bool ledState = false;
#include <LiquidCrystal.h>
LiquidCrystal lcd(18, 5, 17, 16, 4, 0);
int count_1 =0;
int count_2 =0;
void updateLcd()
{
lcd.setCursor(2,0);
lcd.print("count-1 = ");
lcd.setCursor(11,0);
lcd.print(count_1);
lcd.setCursor(2,1);
lcd.print("count-2 = ");
lcd.setCursor(11,1);
lcd.print(count_2);
}
void setup()
{
// put your setup code here, to run once:
lcd.begin(16, 2);
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(buttonPin4, INPUT_PULLUP);
pinMode(buttonPin5, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(buttonPin1)==LOW)
{
count_1++;
updateLcd();
}
if(digitalRead(buttonPin2)==LOW)
{
count_1--;
updateLcd();
}
if(digitalRead(buttonPin3)==LOW)
{
count_2++;
updateLcd();
}
if(digitalRead(buttonPin4)==LOW)
{
count_2--;
updateLcd();
}
if(digitalRead(buttonPin5)==LOW)
{
count_1=0;
count_2=0;
updateLcd();
}
delay(500);
} // this speeds up the simulatioN