I have made a simple object counter which gets triggered by the output of the PIR. The count is shown on the LCD display. I have used Grove LCD for my project
This can be applied to numerous places like a Discotheque, where its important to keep a count of people entering to maintain balance, or a wedding/ family gathering, or any other places where count of people is important like airport, theater, stadium, etc
Step 1: PIR
Passive Infrared sensor measure infrared light radiating from objects in its feild of view
HC-SR501 is the PIR sensor I have used in this project is callibrated to generate a High output in the presence of body heat in its view and low otherwise.
This PIR has a field of view of 120 degrees so you have to be very skeptical about the placement of the sensor.
I suggest placing it in the side of the door do as to narrow its field and thus we do not get double readings
Step 2: Connections
Attach the PIR at the side of the door, Ensure that you have set the optimal sensitivity and set the time delay on the sensor to zero. This is obtained by trial and error (no solution for that :p)
Connect Vin or pir to 3V3, Gnd to Gnd, and Out to pin 3.
Also connect the grove Lcd on the board.
Step 3: Code
In the Loop I'm holding the execution till I get a high output first, then raising the count by one and then holding the count till I get low again, to provide offset of the person passing the gate.
Thus the count only increases by 1 even If the person stands next to PIR and doesnt move.
Step 4: Output
So because this accounts for body heat and not come laser or LDR, there's no need to worry about crossing the junction twice with hands or legs, etc.
The output will look like this, you can even change the color og the display to red and green to direct the person to move and not move.