#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int irSensorPin1 = 4;
const int irSensorPin2 = 2;
LiquidCrystal_I2C lcd(0x27, 16, 2);
int enterCount = 0;
int exitCount = 0;
void setup() {
Serial.begin(115200);
pinMode(irSensorPin1, INPUT);
pinMode(irSensorPin2, INPUT);
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
lcd.print("Enter: 0 Exit: 0");
}
void loop() {
if (digitalRead(irSensorPin1) == HIGH) {
enterCount++;
updateLCD();
delay(1000);
}
if (digitalRead(irSensorPin2) == HIGH) {
exitCount++;
updateLCD();
delay(1000);
}
}
void updateLCD() {
lcd.setCursor(7, 0);
lcd.print(" ");
lcd.setCursor(13, 0);
lcd.print(" ");
lcd.setCursor(7, 0);
lcd.print(enterCount); // Display the updated enter count
lcd.setCursor(13, 0);
lcd.print(exitCount); // Display the updated exit count
}