DIY Bi-Directional Counter Using Arduino & IR Sensors
by Yogeshwaran in Circuits > Arduino
50 Views, 0 Favorites, 0 Comments
DIY Bi-Directional Counter Using Arduino & IR Sensors
 600x500.png)
Have you ever wondered how malls, parking lots, or event venues keep track of people or cars? You might think they use fancy AI-powered cameras, but in most cases, a simple sensor-based system does the job efficiently!
By placing IR sensors at an entry/exit point, the system can detect movement direction and accurately count how many people or objects pass through, No need for complex technology.
Want to Build Your Own Bidirectional Counter?
With just an Arduino and a pair of IR sensors, you can create a real-time counter that:
- Tracks people entering and exiting.
- Displays the current count and history of count on an LCD screen.
What You’ll Learn:
- How to use IR sensors for motion detection.
- Simple hardware and coding tricks to make it work smoothly.
Ready to Get Started?
Follow our, Bidirectional Visitor Counter using Arduino tutorial to get know more details.
Supplies

Here is the list of components needed to build a Bi-Directional Counter Project.
- Arduino UNO R3 board
- Two IR sensors
- 16x2 I2C LCD display
- Breadboard
- Connecting wires
- 12V barrel jack power adapter
Tip:
Before jumping into the circuit diagram, it’s good to first understand, Block diagram of Bi-directional visitor counter. This will help you grasp how the system works more easily.
Designing the Circuit for the Bidirectional Counter

Here’s the circuit diagram for the Bidirectional Counter using Arduino. It shows how the Arduino, two IR sensors, and the LCD display are connected to form a working system.
Why Two IR Sensors?
Using two sensors is necessary to track direction accurately. If you only use one sensor, you won’t be able to tell whether a person is entering or exiting.
Still Confused?
No problem! Check out this detailed guide on "How does IR Sensor detect the direction of Visitor's motion". It explains the concept in a simple and clear way, perfect for beginners!
Building the Hardware Setup


The image above shows the hardware setup of the Bidirectional Counter using Arduino and IR sensors, based on the circuit diagram.
Power Supply:
To power the entire setup, I used a 12V DC adapter connected through a barrel jack.
Need More Help?
Check out this Youtube video to build a Bi-directional Counter using Arduino.
Reduce Interference With an IR Sensor Hack

When using IR sensors in your Bidirectional Counter, they might sometimes pick up unwanted movements from the sides, causing incorrect counts. You can fix this with a simple trick.
How to Do It:
- Cut a small piece of black electrical tape.
- Stick the tape around the sides of the IR sensor.
- Make sure to leave the front open for proper detection.
How It Works:
The black tape blocks signals from the sides, preventing interference from nearby objects or reflections. This makes the sensor more accurate and reliable by only detecting movement directly in front of it.
If you want to know more hack tips, check out this, Tips to avoid false trigger on IR sensor due to environmental conditions.
Write the Code for Your Arduino
Now, let’s move on to the coding part!
How the Code Works:
- The Arduino keeps checking both IR sensors to see which one is triggered first.
- It then verifies if the second sensor is triggered within a set time limit.
- Based on the order of triggers, it decides if someone is entering or exiting.
- The visitor count is updated and shown on the LCD screen.
Want a Detailed Code Breakdown?
For a complete step-by-step code explanation, Feel free to watch out this, Arduino code for Bidirectional Counter article.
Downloads
Upload the Code to Your Arduino


To get your Bidirectional Counter working, you need to upload the code to the Arduino.
How to Do It:
- Open the Arduino IDE on your computer.
- Connect the Arduino board using a USB cable.
- Select the correct board and COM port in the IDE.
- Click the Upload button to send the code to the board.
Having Trouble Uploading?
If you face issues, check out this Article "10 most Common mistakes while using Arduino" to troubleshoot the problem.
Test Your Build

Now comes the most exciting part, testing your project!
What to Expect:
- If everything is connected and coded properly, you’ll see the Bidirectional Counter in action.
- The display will show the current number of people or objects inside.
- It will also keep track of the entry and exit history, showing how many have gone in and out.
Want to See It in Action?
Watch this ,Arduino based Bidirectional Counter working Demonstration
Want to discover more cool projects? Dive into our collection of Arduino IoT Projects | Arduino Robotics Projects | Arduino AI Projects | Arduino Home Automation Projects | Raspberry Pi Projects | ESP32 Projects to inspire your next build!