The problem
Classrooms, seminar halls and laboratories burn electricity for hours with nobody inside because the last person out forgot the switch — or because nobody wants the responsibility of turning the lights off. This project removes the human from the loop: two IR transmitter-receiver pairs mounted a few centimetres apart across the doorway detect not just that someone passed, but which direction they were walking. Breaking the outer beam first and then the inner one means entry (count up); the reverse order means exit (count down). An Arduino Nano keeps the running total on a 7-segment display and drives a relay that powers the room light only while the count is above zero. The result is a room that lights itself for its occupants and goes dark the moment it empties — a small, honest piece of energy saving built from parts any electronics lab already stocks.
Doorway beam pair mounted outside; broken first on entry.
Follow the working sequence
How it works
- Two IR transmitter-receiver pairs are mounted across the doorway about 10–15 cm apart — an outer pair and an inner pair.
- When a person enters, they break the outer beam first and the inner beam second; the Arduino reads this A-then-B sequence as an entry and increments the count.
- When a person leaves, the inner beam breaks first and the outer second (B-then-A); the count decrements, never dropping below zero.
- The firmware debounces each beam (a break must persist a few milliseconds) and discards sequences that do not complete within a timeout window.
- The current count is written to the 7-segment display after every change.
- The relay output follows a simple rule: count greater than zero → light on; count equals zero → light off. The manual override switch bypasses this rule when engaged.
Tech stack:
- Arduino Nano (ATmega328P)
- IR transmitter-receiver sensor pairs × 2
- 7-segment LED display
- 5V relay module (SRD-05VDC-SL-C)
- Push-button (reset) + toggle switch (override)
- 5V regulated power supply
- Buzzer (optional occupancy alert)
- Arduino IDE (C++ firmware)
| Parameter | Value |
|---|---|
| Sensing | 2 × IR beam pairs, approximately 10–15 cm spacing (design) |
| Controller | Arduino Nano, ATmega328P at 16 MHz |
| Display | Single-digit 7-segment (0–9; two-digit as buyer option) |
| Relay contacts | 10 A at 250 VAC (SRD-05VDC-SL-C datasheet) |
| Supply | 5 V DC regulated for logic; relay switches mains load |
| Count logic | Entry = outer-then-inner break; exit = inner-then-outer |
| Debounce | Approximately 20 ms per beam (design) |
| Sequence timeout | Approximately 3 s for incomplete passes (design) |
| Override | Manual toggle, light forced on with indicator LED |
Project features
- [Bidirectional counting] Two IR beam pairs read the break sequence to distinguish entry from exit, so the count tracks real occupancy instead of just motion.
- [Automatic light control] A 5V relay module switches the room light on when the count rises above zero and off when it returns to zero — no switches to remember.
- [Live count display] A 7-segment display shows the current number of people inside, useful for the demo and for the room's own awareness.
- [Debounce and sequence logic] Firmware ignores partial beam breaks and times out incomplete sequences (someone who steps in and backs out), keeping the count stable.
- [Manual override] A toggle switch forces the light on regardless of count for cleaning and maintenance, with an indicator LED showing override state.
- [Reset function] A push-button zeroes the count for resynchronisation, documented as part of the operating procedure.
- [Single 5V supply] The logic side runs from one regulated 5V adapter; the relay contacts are rated for standard 230V room lighting loads.
What is included
- Assembled and tested prototype (Arduino Nano, IR pairs, display, relay module, switches)
- Complete firmware source with direction/debounce logic
- Circuit diagram and doorway mounting layout
- Operating and resynchronisation procedure
- Project report PDF (IR sensing, direction logic, relay driving, methodology)
- PPT presentation for final review
- Viva Q&A preparation document (beam sequencing, debouncing, relay isolation, occupancy edge cases)
- Bill of materials with sourcing pointers
Limitations & prerequisites
- Two people entering shoulder-to-shoulder break both beams as one body and count as a single entry — the design assumes single-file passage.
- If someone stands in the doorway blocking a beam, the count can drift; the reset button and the documented resync procedure recover it in seconds.
- The single-digit display reads 0–9; rooms expecting larger crowds need the two-digit display option noted in the report.
- The relay switches the light circuit, so mains wiring must be done with proper insulation and, where local rules require, a licensed electrician.
- This is an occupancy convenience control, not a security or attendance system — it cannot identify who entered.
- Bright direct sunlight on the receiver side can swamp IR photodiodes; the sensors should be shaded from direct sun at the doorway.
Frequently Asked Questions
How does it know whether someone is entering or leaving?
Two IR beams sit a few centimetres apart across the doorway. Entering breaks the outer beam first, then the inner — the firmware reads that order as +1. Leaving breaks them in the reverse order, which reads as −1. One beam alone could never give direction.
What happens if someone walks in and immediately walks back out?
The firmware requires a complete A-then-B (or B-then-A) sequence within a timeout window. A half sequence that times out is discarded, so aborted entries do not corrupt the count.
Can it handle a classroom of 60 students?
As shipped the display reads 0–9 and the logic is exact for single-file entry, which suits labs and small halls. The report documents the two-digit display upgrade for larger rooms.
Is the mains switching safe?
The relay module's contacts are rated 10 A at 250 VAC (datasheet), with opto-isolation between the Arduino side and the mains side. Mains connections still demand proper insulation and careful wiring.
What if the count drifts over a long day?
The reset button zeroes the count instantly; the operating procedure recommends a resync when the room is known empty (e.g. morning opening). Drift sources and recovery are covered in the report.
Is this project suitable for a final-year project?
Yes — for Electronics and E&TC programs. It demonstrates sensor interfacing, sequential logic, debouncing, relay driving with isolation, and a working energy-saving application. Suitable for B.E./B.Tech final-year projects in Electronics and E&TC.
Components & software requirements
- Arduino Nano (ATmega328P)
- IR transmitter-receiver sensor pairs × 2
- 7-segment LED display
- 5V relay module (SRD-05VDC-SL-C)
- Push-button (reset) + toggle switch (override)
- 5V regulated power supply
- Buzzer (optional occupancy alert)
- Arduino IDE (C++ firmware)
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and email — the synopsis PDF downloads immediately. We may send occasional project updates; no spam, unsubscribe anytime.