Automatic Bidirectional Visitor Counter With Light Control Using Arduino

We will discuss in today’s topic, how can we build a simple Infrared Sensor Based Automatic Bidirectional Visitor Counter using Arduino. Often we see automatic bidirectional visitor counters at stadiums, malls, offices, etc. How does this single device count people when they enter or exit from the compound?

Today we will discuss its principle, and how it works. The main intention is to design a circuit where the number of persons entering or leaving a compound or room is kept track of and displayed on an LCD screen. It is definitely an interesting mini project for hobbyists and students for fun as well as learning. So let’s do this. Before going to the project, first, check out how to build an Infrared Sensor.

Principle Behind Bidirectional Visitor Counter

The principle behind this bidirectional visitor counter is infrared sensing. Infrared or IR sensor is a device that works with infrared rays and an infrared receiver like a Photo Diode or a Photo Transistor that act as a Transmitter and Receiver respectively.

In this project, we have used an IR LED as the IR Transmitter and a Photo Diode as the IR Receiver. Two sets of IR sensors containing of an IR LED and Photo Diode are placed at two ends of the entrance of a room.

Output from each sensor is detected by the Arduino. In the normal state, IR rays from the IR Transmitter would not fall onto the Photo Diode as it is a reflective type IR Sensor. The output from the IR sensor would be a logic LOW state in this case.

In case of any interruption (Due to any person crossing the entrance), the Photo Diode would start receiving the IR rays and start conducting the current. As a result, the output from the sensor would be a logic HIGH state.

The transition from LOW to HIGH, for each sensor pair, is detected by the Arduino and accordingly the count would be increased or decreased.


Bidirectional Visitor Counter
Bidirectional Visitor Counter

Circuit Diagram

Automatic Visitor Counter Circuit Diagram
Automatic Visitor Counter Circuit Diagram

Components Required

  • Arduino Nano
  • 16×2 LCD Display
  • Infrared Sensor Module (x2)
  • 5V Relay
  • BC547 NPN Transistor
  • Resistor (1KΩ, 220Ω)
  • Hi-Link 5V AC-DC Converter (Optional)
  • AC Source

Circuit Explanation

The project of “Bidirectional Visitor Counter” is based on the interfacing of some components such as sensors, microcontroller, counter display and gate.

Sensor Part: In this part, we have used two IR sensors which contain IR LEDs, Photo Diodes, potentiometer, comparator (Op-Amp) and LEDs. The potentiometer is used here for setting up reference voltage at the comparator’s one terminal and IR sensors sense the object or person and provide a certain change in voltage at the comparator’s second terminal. Then comparator compares both these voltages and generates a digital signal at the output terminal. Here we have used two comparators for two sensors. LM358 is used as a comparator. LM358 has inbuilt two low noise Op-Amp.

Control Part: Arduino is used for controlling the whole process of this bidirectional visitor counter. The outputs of comparators are connected to pin 14 and pin 19 of the Arduino. Arduino then read these signals and send commands to the relay module to drive the load for control.

Counter Display Part: The display part contains a 16×2 LCD display. This section will show the counted number of people entering or exiting from the room and light status when no one will be in the room.

Relay Module Part: The relay module consists of a BC547 NPN transistor and a 5-volt relay for controlling the load (light bulb). Transistor is used to drive the relay because Arduino does not supply the required voltage and current to drive the relay. So we have added a transistor in this circuit to get enough voltage and current for the relay. Arduino sends signals to this driver transistor and then the light bulb will turn on and off accordingly.

Applications of Bidirectional Visitor Counter

The Bidirectional Visitor Counter device can be used in the home as an indication of a number of persons entering a party.

It can be used at official meetings.

At secured official places, this device can keep a check on the number of persons entering a secured place.

It can also be used as a home automation system to ensure energy saving by switching on and off the loads only when needed. 

Disadvantages of Bidirectional Visitor Counter

This project has the capability of low range and cannot be implemented in large areas.

With the frequent changes of the count, after a certain time, the output may be confusing.

Arduino Code Without I2C Module

Arduino Code With I2C Module

1 thought on “Automatic Bidirectional Visitor Counter With Light Control Using Arduino”

Leave a Comment