A Bi-Directional person / object counter is a device which can be used to monitor the number of objects entering / exiting through it. It has a wide range of applications including automatic parking slots monitoring , number of people entering / exiting a mall , number of students in a class , et cetera.

It has two variants :

1. Laser diode and LDR combination

2. IR led and photodiode combination

The laserdiode-LDR version can be used where the distance between the source ( laserdiode ) and the sensor ( LDR ) is large whereas the IR-PhotoDiode can only be used for short distances and is comparatively less accurate.

Step 1: Part List

Parts you'll need for making this project :

1.2 x Laser-Diodes ( I've used a laser-diode from a red laser pointer - 635nm and <1mW )

2. 2 x Small LDRs

3. 2 x 10k ohm resistors

4. 1 x 7805 - 5v voltage reg.

5. Arduino ( any microcontroller would serve the purpose )

6. Heat Shrink tubing ( 4mm )

7. PerfBoard

8. 9v battries and battery connectors

Step 2: Schematics

Circuit # 1 :

Two LDRs are connected to the A0 and A1 analog pins of arduino . One leg of the LDR is grounded and the other end is connected to +5v through a 10k ohm pull-up resistor. The Junction of the LDR's leg and the resistor is connected to the analog pin.

When the resistance of the LDR goes below 10k ohm , the analog pin reads 0 v and if it goes above 10k ohm , the analog values will be displayed accordingly.

Circuit # 2 :

This circuit just converts 9v to 5v using 7805 voltage regulator to drive the Laser Diodes. A 10k ohm pot is added to protect the Laser Diodes. Two laser diodes are connected in parallel to the power source.

Display Circuit :

If you don't want to use the serial monitor to display the counter values then you can add 2 x seven segment displays to the arduino's digital pins as shown ( you can also use a multiplexer if you want ).

Step 3: Layout and Working

There're two parts of the counter :

1. Laser source

2. Sensor plate


The two laser diodes are connected in parallel to a +5v regulated power source. On the other side , two LDRs are connected to arduino . They are placed such that both the laser beams fall directly on the LDRs.

A 2 x 7 segment display is connected to the arduino to display ( total no. of objects entering - total no. of objects leaving ). This can also be done by using the Arduino serial monitor.


In normal position , the beams fall directly on the LDRs and hence the resistance of the LDRs drops down drastically . As the resistance goes below 10k Ohm , the analog pin will read a lower analog value. When an object enters , the first beam ( beam A ) breaks before second beam ( beam B ) , the counter will increase by 1 . As beam B breaks before beam A , the counter will decrease by 1.

Step 4: Programming Part

There are two programs in the Archive

1. For Serial monitor

2. For 7-segment display


Download the archive and choose your program ,

Upload it to your arduino and open the serial monitor to check the value of both the sensors in normal and breached positions and set the threshold accordingly.

After you've checked the counter and calibrated the sensors , you can now attach your LCD / seven-seg display.


The program reads the sensor values and compares them with the threshold value , in normal state the counter will be constant. As one of the beam breaks , the counter is increased or decreased by 1 . The program also calculates the time for which the object stays between the source and the sensors and suspends the program for that time duration to avoid false readings.


Feel free to ask questions and if you like my ible , please vote for me !

<p>for Laser diode and LDR combination, what can be the max distance between the two?</p>
<p>Greetings!</p><p>I was curious if you would be willing to make a couple of these for me? I am trying to figure out a way to monitor the number of people that pass in front of my table at a conference. There are a couple of modifications, but we can talk more about that if you are interested. Shoot me an email at olsonb2@gmail.com.</p><p>Thanks,</p><p>Brad</p>
<p>friend i need help</p><p>i made ir base project using arduino uno</p><p>how to define when first time sensor output on then then off after 5 sec..</p><p>i made project when counter = 2 then do condition &amp; counter = 3 then other condition.but problem is i want to check how many time my hand in front of ir sensor within 10 second ..also problem is when counter =3 when ir detect 3 motion but before that counter =2 condition is satisfy then this loop run after then counter = 3 condition run...how to solve ...please help ...any expert </p>
<p>I would like to send count on my server and php script is runnig over there to accept the count so how could I do the same?</p><p>How can I make internet available to arduino?</p>
<p>I hope you found the answer. If not, check out Arduino ethernet shield (costly option) or check out ESP8266 (extremely cheap option). PM me if you still needs more help</p>
<p>will this system work without using a photodiode? we can just use the IR sensors for the detection. if sensor A gets notified first, increment the counter. if sensor B gets notified first then decrement. is that possible?</p>
<p>the 7 seg still not working correctly.. help?? whats the problem? </p>
<p>I need a bit more specific information about the problem that you're encountering. Did the 7 segment fry up ? and did you check the connections properly ? Try using a DMM and figure out whether it is a common anode or common cathode.</p>
<p>Counter is working very fine in arduino serial monitor, but there was a problem when I tried to display using LED 7 segment. Anyhow I made it and enjoyed the work.</p>
<p>can you help me with the ciruit to connect it ? please</p>
Yeah sure tell me where you are struck .
<p>hey ... can u tell me how to make the 7 segment work .. urgent </p>
Sorry for the delay. Parts Arduino board, laser light and LDR is only needed. 7405 voltage is necessary if you are using 9 v battery. Go through the instructable and you don't even need 7 segment display. You can view it in console itself.
I have a confussion, if some one cuts the first beam but don't cut the second beam, then returns again cutting the 1st beam, then the counter will be increased or decreased by 2,, how you have solved this problem??
How can i program write a program to allow only a set no of visitors in the room if the number is exceeded a warning is displayed?
Just add an &quot;if&quot; statement in the &quot;void loop ()&quot; function.<br>Something like,<br><br>if (count &gt;= max )<br>{<br>*add the action you want to do after count exceeds max count*<br>}<br> <br>I hope it helps :)
<p>7 segmnt not working :( please help ...urgent</p>
<p>where and how to place this project because we can't determine the body language and walking style of that person..............</p>
<p>can a Raspberry Pi replace the Adruino in this case?</p>
<p>or how to attach LCD instead of 7 segment display</p>
<p>how to attach 3 or 4 digit 7 segment display</p>
<p>please can i get the block diagram, or can you please send it to my mail</p>
<p>did you get the diagram? if you do can send it to my mail please.</p>
<p>how do u make ambient compensation ?</p>
<p>can i ask the pin configuration if using 16 x 2 display and codes too ?</p><p>i've used the 2 of 7-segment display but it's not displaying correctly</p>
<p>Here's a general question I'm not sure where to ask. How do I extract the &quot;BI-Directional Couter.rar&quot; code ?</p>
<p>I have a question about the combinations.. can i use laser diode and LDR combination in short range? </p>
I have a question about the 7seg display if i want to use anode or cathode. Does it matter either way ? My instructor said it needs a driver to connect in my arduino or sumtn ?
<p>Yes, it does matter. I've used a common cathode 7 Segment display in this project. I preferred not to use a driver because I had sufficient amount of pins for two 7 segments, though you may use a multiplexer if you want to use more than one 7 segments !</p>
Also the 10k ohm resistor. 1/4th , 1/8th or does it matter ? Sorry for my noobish question, i'm not really that knowledgable
<p>The power of the resistor doesn't matter here because the 10K resistor and the LDR form a voltage divider. The current that passes through the network is very less so a 1/4 watt or any other 10K should work fine.</p>
<p>Can I ask what's the use of heat shrink tubing in this project ?</p>
<p>heloo,i have a raspberry pi model b+,can you help me do this project using it?</p>
<p>I've tried this with the serial monitor, but I didn't get it to work right. :( Also, may I ask what are these variables for? Thanks! <br>int lights=9;</p><p>int sens_cutoff=A2;</p><p>int relay=2;</p>
<p>I want the coding for this project</p>
<p>The codes are already uploaded on the page !</p>
<p>hii i am trying to make this project. i have a question that how will we load the program to arduino</p>
<p>To upload the program, you'll need a USB-B type cable ( in case of UNO ) or a micro USB ( in case of Leonardo ) <br>Then you can easily use the official IDE to upload the code !</p>
<p>please help me to do this project using more than two 7-segment display that can count above 99 persons.</p>
<p>For doing that, you've got two options- either use a 16 x 2 LCD or multiplex the outputs so that they can drive 3 or more seven segments. Using an LCD is the best and the easiest way that would serve the purpose.</p>
<p>I love this project, I want to build it but I need it to count down, is that possible? Also how accurately would it count objects moving at fast speeds?</p>
<p>Yes you can do that ! It is pretty accurate in counting fast moving objects too ( specially the LASER version ).</p>
Hi sir! Im a fan of your work. I tried making this project. But i encounter some problem. Im using two 7segment display but the display is not workiing properly. The rx and tx or pin 0 and pin 1 is usually on. The digit on the tens place
<p>Thanks :)</p><p>It seems that you're using Serial.begin() or any other function that uses Serial monitor. That's why the segments on pin 0 and pin 1 are always 'on'. Try removing the instances from your program. If it still doesn't work , then send me the program through PM. </p>
Hope you can help me. Thankyou
<p>can i use a 2 digit seven segment display? If yes can I have a schematic diagram of it connecting to the arduino.. </p>
<p>I think this project requires one door for entry and another door for exit purpose!</p>
<p>This project would work even if there is a single door, but it won't support simultaneous entry or exit or both.</p>

About This Instructable




Bio: Hey there ! I'm Tanay , a hobbyist interested in making robots and sharing stuff. I hope that my instructables help you in solving your problems ... More »
More by electro18:USB Chameleon Lamp ( Color replicating ) Your Own Color Sensor using LEDs Measure RPM - Optical Tachometer  
Add instructable to: