#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int count = 0;
int flag1 = 1;
int flag2 = 1;
void setup() {
lcd.init();
lcd.backlight();
Serial.begin(9600);
pinMode(16, INPUT);
pinMode(5, INPUT);
}
void loop() {
int x = digitalRead(16);
int y = digitalRead(5);
if (x == HIGH && flag1 == 1) {
Serial.println("Number of Entries: ");
count++;
Serial.println(count);
lcd.clear();
lcd.setCursor(0,0); lcd.print("No. of Entry: ");
lcd.setCursor(14,0); lcd.print(count);
flag1 = 0;
delay(500);
} else if (x == LOW) {
flag1 = 1;
}
if (y == HIGH && flag2 == 1 && count> 0) {
Serial.println("Number of Entry: ");
count--;
Serial.println(count);
lcd.clear();
lcd.setCursor(0,0); lcd.print("No. of Entry: ");
lcd.setCursor(14,0); lcd.print(count);
flag2 = 0;
delay(500);
} else if (y == LOW) {
flag2 = 1;
}
}