/homemade_items


Post here everything you can do with homemade items that are truly useful. Who's going to go first?


Members: 4
Join


Moderated by: x1012
up
3
up
PaulG 1784316190 [homemade_items] 1 comments
Ever noticed how stores, libraries, and even event venues seem to know exactly how many people walked in and out throughout the day? Behind that simple number, there's almost always an infrared sensor quietly doing the work. And here's the good news: this is one of the most rewarding projects for anyone getting started in electronics — it uses just a handful of components, the code is short, and the end result is something you can actually show off working in real time. In this tutorial we're going to build a people counter using an infrared beam-break sensor module connected to an Arduino. Every time someone interrupts the infrared beam, the system logs a pass and updates the count. Simple in theory, but with practical details that make all the difference between a project that works well and one that gives you headaches in the first week. ## What you'll need This project doesn't require expensive parts or specialized tools. An Arduino Uno (or any compatible clone) serves as the brain of the system. Then you'll need an infrared beam-break sensor module — usually sold with the emitter and receiver as two separate pieces, ready to place on either side of a doorway or corridor. Add a 16x2 LCD screen with an I2C module, which will make wiring things up much easier, and an optional small buzzer, which is genuinely helpful during testing since it gives you an audible cue every time the beam is broken. Jumper wires, a breadboard, and a USB power source round out the list. ## How the sensor actually works Before wiring anything up, it's worth understanding the logic behind the system, since it'll help you enormously if something doesn't work as expected. The infrared emitter continuously sends a beam of light invisible to the human eye toward the receiver. As long as that beam arrives uninterrupted, the receiver keeps its output in one state (typically high). The moment a person walks through the corridor and blocks the beam, even for a fraction of a second, the receiver detects the absence of light and switches its output to low. That transition, from beam present to beam broken, is what the Arduino will interpret as "someone just passed." ## Building the circuit Start by positioning the emitter and receiver facing each other, aligned at roughly waist height for an adult, with a gap between them that can be up to two or three meters depending on the module you bought. Connect the receiver's output pin to a digital input on the Arduino, pin 2 for example, and connect the power and ground of both modules to the Arduino's 5V and GND pins. If you're using the LCD screen with an I2C module, wiring gets even simpler, since you only need four wires: power, ground, SDA, and SCL, typically connected to pins A4 and A5 on an Arduino Uno. One detail that makes a real difference in practice is making sure the emitter and receiver stay properly aligned with each other. A misalignment of just a few millimeters can already weaken the signal and cause false readings, so it's worth testing the alignment before mounting everything permanently in place. ## The code that brings it to life The code for this project is simpler than it looks at first glance. The core idea is to continuously monitor the state of the pin connected to the receiver and detect the exact moment it switches from high to low, which is the instant the beam gets broken. Every time that transition happens, we increment a counter variable and update the LCD screen with the new value. ```cpp #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); const int sensorPin = 2; int counter = 0; int previousState = HIGH; void setup() { pinMode(sensorPin, INPUT); lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("People: 0"); } void loop() { int currentState = digitalRead(sensorPin); if (currentState == LOW && previousState == HIGH) { counter++; lcd.clear(); lcd.setCursor(0, 0); lcd.print("People: "); lcd.print(counter); delay(500); // prevents duplicate counts from the same pass } previousState = currentState; } ``` Notice the short half-second delay after each count. That detail exists because a single person walking through can trigger more than one beam-interruption reading, especially if they walk slowly or hesitate midway. Without that delay, your counter will start "seeing" extra people, which is frustrating to debug if you don't know where the error is coming from. ## Testing and fine-tuning the system With everything assembled, the next step is testing under real conditions. Walk through the beam several times, at different speeds, and check whether the count keeps up correctly. If you notice duplicate counts, slightly increase the delay value in the code. If you notice some passes aren't being detected at all, check the physical alignment between emitter and receiver, since that's usually the main culprit. It's also worth testing under different ambient light conditions, especially if you're planning to install the sensor near a window, since direct sunlight can interfere with infrared readings on some of the simpler modules. ## Where to take the project next Once you've got the basic version working, there's a natural path forward worth exploring. You can distinguish entries from exits by using two sensors in sequence, which turns your simple counter into a system capable of tracking not just how many people passed by, but how many are actually inside the space at any given moment. You could also send the data online using an ESP8266 or ESP32 module instead of the Arduino Uno, which opens the door to logging counts into a spreadsheet or an online dashboard, letting you track movement throughout the day from your phone. ## Now it's your turn You've got everything you need here to build your first infrared people counter, from picking the components to the final tested code. The most important part now is sitting down at the table, wiring things up, and watching the count climb with your own footsteps. Build yours, test it out, and let us know how it went: share a photo of your circuit or a video of the sensor in action in the comments, and if you ran into any questions along the way, drop them and we'll be happy to help.
up
0
up
mozzapp 1784316398
This is the kind of content I like reading here the most. I try out some of these things whenever I can (y)

A social news and discussion community