Arduino-DIY Laser / IR Person Counter





Introduction: Arduino-DIY Laser / IR Person Counter

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 !



  • Microcontroller Contest

    Microcontroller Contest
  • Science of Cooking

    Science of Cooking
  • Pocket-Sized Contest

    Pocket-Sized Contest

We have a be nice policy.
Please be positive and constructive.




I need help, i wan tu upload the progam in the arduino and say:

Sketch uses 2272 bytes (7%) of program storage space. Maximum is 32256 bytes.

Global variables use 260 bytes (12%) of dynamic memory, leaving 1788 bytes for local variables. Maximum is 2048 bytes.

avrdude: ser_open(): can't open device "COM1": No such file or directory

Problem uploading to board. See for suggestions.

thanks for this project.

Also be free to email back:

In the arduino ide go to tools>port and select the right choice... ;)

for Laser diode and LDR combination, what can be the max distance between the two?

it depends on the laser light to maintain the intensity and max distance

Hiya, ive made the entire circuit, ive made the seven segment display version. But im having problems with the programming. Random segments on the seven segment displays show up, and they don't change :( HELP


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



friend i need help

i made ir base project using arduino uno

how to define when first time sensor output on then then off after 5 sec..

i made project when counter = 2 then do condition & 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 to solve ...please help ...any expert

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?

How can I make internet available to arduino?

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

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?