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.

PCB Design

For removing messy wiring and give a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I prefer PCBWay.

Gerber file for Automatic Visitor Counter Gerber.

PCB View

Automatic Visitor Counter 2D View
2D View
Automatic Visitor Counter 3D View
3D view

Order PCB From PCBWay

PCBs are the neatest and professional-looking among the assembled circuit types. Any electronics circuit that needs to be professional looking uses PCB boards. But soldering is still required on the copper area on the PCB. In the early 1900s, the only way to make circuits for electrical or electronic components was by wiring them point to point on a chassis. These chassis were either pan or sheet. These methods made circuits very fragile and large or bulky, and expensive.

There are so many forums or communities for electronics online in today’s technical world, and one of the famous ones for PCB manufacturing is the PCBWay. PCBWay is a place that brings manufacturers and customers together. They have more than a decade of experience in this field of fabrication and prototyping and assembling of PCBs. PCBWay have proved their focus to their customers’ needs in terms of cost-effectiveness, delivery, and quality. And this can be proved by their outstanding customer reviews. This PCBWay provided a platform for students and electronic hobbyists to display their projects to the community and give sponsorships if their work is attractive. Check out the large pool of sponsored projects here.

How PCB Manufacturing Process Done in PCBWay

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity by quality control in designing and manufacturing. At first, they ensure accuracy, clarity, validity of the PCB files that we sent to them.

Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Tester, X-Ray Inspection Machine, Automated Optical Inspection (AOI) Machine. PCBWay are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust for their reliable quality. They produce high-quality pink, orange, grey, even transparent solder mask. Moreover, according to people needs, they can also provide Black core PCB. Check it out for a High-Quality PCB solder mask. There are some pictures below of the new colours of solder musks.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.

PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly service but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.

3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.

Services: PCBWay offers great servicing of their products. It takes only 3 to 15 days according to courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.

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