e18-d80nk SENSOR and 16x2 lcd display with arduino uno

Hi I wanted to make this code that can count IN and OUT visitor COUNTER

but this code only works on 1 (e18-d80nk ) sensor I wanted to work the code with two IR sensor here is the sample code with 1 sensor only

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define counter_pin 7
LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

bool item_detected = false;
int item_counter = 0;

void setup()
{
Serial.begin(9600);
pinMode( counter_pin , INPUT);

lcd.init(); // initialize the lcd

// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(“Hello, world!”);
lcd.setCursor(2,1);
lcd.print(“Ready… :)”);
delay(3000);
}

void loop()
{
int val = digitalRead( counter_pin );
if( (item_detected == false) && ( val == 0 )){
item_detected = true;
item_counter++;
updateCounter();
}

else if( (item_detected == true) && ( val == 1 )){
item_detected = false;

}
}
void updateCounter(){

lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Item count”);
lcd.setCursor(0,1);
lcd.print(item_counter);
}

what changes do i need so that the dsiplay will display how much visitor is in a room?

when 1 person ENTER it will display on the LCD then if the person getout on the ROOM it will turn to zero

If you want it to work with 2 sensors, you will need to define a second pin to use for the second sensor. You will then have to read both sensors to see if somebody is coming in (sensor 1 then sensor 2 tripped) or going out (sensor 2 tripped then sensor 1).

Write some code and give it a try. Report back if you have trouble. Also, read the sticky post at the top of the forum about how to properly post your code using code tags. It will help people help you.

@kalilinux25 has another thread about the same project. At a glance, I can't tell whether it's a cross-post or not, but certainly it's very similar, and thus has the potential to result in duplicate efforts:

blh64:
You will then have to read both sensors to see if somebody is coming in (sensor 1 then sensor 2 tripped) or going out (sensor 2 tripped then sensor 1).

I started my reply in the other thread along those lines, but then saw that the code the OP posted there (not the same as that here) seemed to have an in-sensor and an out-sensor, like 2 doors.

The code I eventually provided there matches what I thought; one for in and one for out. But blh64 may well be right, I'm not sure.

Seems OP is just blindly throwing code at this until some sticks; I provided code in the other thread since it just seemed the OP was going to flounder and drown. But they need to clarify the issue of how the count actually works. My code may well be wrong (or rather the code is right but my assumption / understanding may be wrong.)