The Infrared Light Barrier Alarm is a security system that uses an infrared transmitter and receiver pair to detect interruptions in an invisible IR beam, triggering an alarm (buzzer and LED) via an Arduino microcontroller when an object or person breaks the beam. This system is ideal for doorway security, object detection, intruder alerts, and automation in homes, offices, and industrial areas due to its invisible detection, customizable sensitivity, low power consumption, and compact design. It works by transmitting a continuous IR beam, detecting interruptions, and activating alerts, making it cost-effective, easy to build, and scalable for various applications. Future enhancements could include wireless connectivity, IoT integration, advanced logic for false-alarm filtering, and solar power for off-grid use, ensuring it remains a versatile and reliable solution for safety and security needs.
The primary objectives of this project are to design and implement a light barrier security system utilizing an infrared (IR) transmitter and receiver pair, enabling the detection of obstructions in the IR beam and triggering an alarm mechanism—such as a buzzer and LED—through an Arduino microcontroller. This system aims to provide a practical understanding of how infrared sensors function in security applications, demonstrating their ability to detect intrusions or movements by monitoring interruptions in the invisible IR beam. By achieving these goals, the project highlights the system’s potential for real-world applications, including doorway security, intruder alerts, object detection, and automation in residential, commercial, and industrial settings, while also fostering a deeper comprehension of IR technology and its integration into electronic security solutions.
Components Required
- Arduino Uno/Nano – Processes sensor data and activates the alarm.
- IR Transmitter (IR LED, 940nm) – Sends an invisible infrared beam.
- IR Receiver (Photodiode or TSOP1738) – Detects the IR beam from the transmitter.
- Buzzer – Sounds an alarm when the beam is interrupted.
- LED – Lights up when the beam is broken.
- 10kΩ Resistor – Used with the IR receiver for stable readings.
- 220Ω Resistor – Limits current to the LED.
- 5V Relay Module (Optional) – Can trigger external devices like alarms or lights.
- Jumper Wires – For making connections.
- Breadboard – For assembling the circuit.
- 5V Power Supply (USB or Battery) – Powers the system.
Circuit Diagram
- Connecting the IR Transmitter (IR LED) to Arduino
The IR LED acts as the transmitter, continuously sending an invisible infrared beam.
- Anode (+) of IR LED → Connect to D3 on Arduino (allows control of IR beam emission).
- Cathode (-) of IR LED → Connect to GND on Arduino.
Note: The IR LED can be constantly ON or pulsed for power efficiency
2. Connecting the IR Receiver to Arduino
The IR receiver detects the IR beam and changes its output when the beam is interrupted.
For a photodiode-based IR receiver:
- Anode (+) of IR receiver → Connect to 5V on Arduino.
- Cathode (-) of IR receiver → Connect to A0 on Arduino (reads the sensor output).
- One leg of a 10kΩ resistor → Connect to A0 on Arduino.
- Other leg of the 10kΩ resistor → Connect to GND on Arduino.
For a TSOP1738 IR receiver module:
- VCC → Connect to 5V on Arduino.
- GND → Connect to GND on Arduino.
- OUT → Connect to D2 on Arduino (detects IR beam interruptions).
3. Connecting the Buzzer and LED to Arduino
When the IR beam is blocked, the buzzer and LED activate as an alert.
- Buzzer Positive (+) → Connect to D8 on Arduino.
- Buzzer Negative (-) → Connect to GND on Arduino.
- LED Anode (+) (Longer Leg) → Connect to D7 on Arduino through a 220Ω resistor.
- LED Cathode (-) (Shorter Leg) → Connect to GND on Arduino.
4. Connecting a Relay Module (Optional, for External Alarm Systems)
If you want the system to control a door lock, siren, or security system, connect a 5V relay module:
- VCC → 5V on Arduino.
- GND → GND on Arduino.
- IN (Control Signal) → D9 on Arduino (activates external devices when the beam is interrupted).
5. Powering the System
Use a stable 5V power source:
- USB Power Bank → Connect to the Arduino’s USB port for continuous power.
- 9V Battery → Connect the positive terminal to VIN and negative terminal to GND.
DO NOT connect 9V directly to the 5V pin, as it would damage the Arduino board.
Code
#define IR_SENSOR 2
#define BUZZER 8
#define LED 7
#define RELAY 9 // Optional, for triggering external devices
void setup() {
pinMode(IR_SENSOR, INPUT);
pinMode(BUZZER, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(RELAY, OUTPUT);
digitalWrite(BUZZER, LOW);
digitalWrite(LED, LOW);
digitalWrite(RELAY, LOW);
Serial.begin(9600);
}
void loop() {
int beamStatus = digitalRead(IR_SENSOR);
if (beamStatus == LOW) { // IR beam is interrupted
digitalWrite(BUZZER, HIGH);
digitalWrite(LED, HIGH);
digitalWrite(RELAY, HIGH);
Serial.println("Intrusion Detected! Alarm Activated!");
}
else { // Normal condition (IR beam detected)
digitalWrite(BUZZER, LOW);
digitalWrite(LED, LOW);
digitalWrite(RELAY, LOW);
Serial.println("No Intrusion.");
}
delay(100);
}
CODE EXPLANATION
1. Pin Definitions
- IR_SENSOR 2: The IR receiver is connected to digital pin 2. It detects whether the IR beam is interrupted.
- BUZZER 8: A buzzer is connected to digital pin 8 to produce an audible alarm.
- LED 7: An LED is connected to digital pin 7 to provide a visual alarm.
- RELAY 9: A relay module (optional) is connected to digital pin 9, which can be used to control external devices like lights or sirens.
#define IR_SENSOR 2
#define BUZZER 8
#define LED 7
#define RELAY 9 // Optional, for triggering external devices
2. Setup Function
- pinMode(): Configures the specified pins as either INPUT or OUTPUT.
- IR_SENSOR is set as INPUT to read the status of the IR beam.
- BUZZER, LED, and RELAY are set as OUTPUT to control their states.
- digitalWrite(): Initializes the buzzer, LED, and relay to LOW (off) at startup.
- Serial.begin(9600):Starts serial communication at 9600 baud rate for debugging and monitoring via the Serial Monitor.
void setup() {
pinMode(IR_SENSOR, INPUT); // Set IR sensor pin as input
pinMode(BUZZER, OUTPUT); // Set buzzer pin as output
pinMode(LED, OUTPUT); // Set LED pin as output
pinMode(RELAY, OUTPUT); // Set relay pin as output
digitalWrite(BUZZER, LOW);
digitalWrite(LED, LOW);
digitalWrite(RELAY, LOW);
Serial.begin(9600);
}
3. Loop Function
- digitalRead(IR_SENSOR): Reads the current state of the IR sensor.
- LOW indicates the IR beam is interrupted (intrusion detected).
- HIGH indicates the IR beam is intact (no intrusion).
- if (beamStatus == LOW):
- If the beam is interrupted, the buzzer, LED, and relay are turned on (HIGH).
- A message is printed to the Serial Monitor: 🚨 Intrusion Detected! Alarm Activated! 🚨.
- else:
- If the beam is intact, the buzzer, LED, and relay are turned off (LOW).
- A message is printed to the Serial Monitor: No Intrusion.
- delay(100): Adds a 100ms delay to stabilize the loop and prevent rapid toggling of the alarm.
void loop() {
int beamStatus = digitalRead(IR_SENSOR); //
if (beamStatus == LOW) { // IR beam is interrupted
digitalWrite(BUZZER, HIGH); // Turn on buzzer
digitalWrite(LED, HIGH); // Turn on LED
digitalWrite(RELAY, HIGH); // Turn on relay (optional)
Serial.println("Intrusion Detected! Alarm Activated!");
}
else { // Normal condition (IR beam detected)
digitalWrite(BUZZER, LOW); // Turn off buzzer
digitalWrite(LED, LOW); // Turn off LED
digitalWrite(RELAY, LOW); // Turn off relay
Serial.println("No Intrusion.");
}
delay(100); // Small delay for stability
}
How It Works Together
1. The IR transmitter (IR LED) continuously emits an invisible infrared beam.
2. The IR receiver (photodiode or TSOP1738) detects the beam under normal conditions.
3. When an object blocks the IR beam, the Arduino detects the change and activates the alarm.
4. The buzzer sounds, and the LED turns on, indicating an interruption in the IR barrier.
5. If a relay module is connected, it can trigger an external alarm or door lock mechanism.
Observing Functionality
1. When the IR transmitter and receiver are aligned, the alarm remains OFF.
2. When an object interrupts the IR beam, the buzzer sounds, and the LED turns on.
3. If a relay is connected, it activates an external security device.
4. The Serial Monitor displays real-time detection messages.
POSSIBLE PROBLEMS AND SOLUTIONS
1. False Alarms?
- Ensure the IR transmitter and receiver are perfectly aligned.
- Shield the sensor from strong ambient light (e.g., sunlight or bright LEDs).
2. Buzzer Not Sounding When Beam is Broken?
- Check if the buzzer is connected properly to D8 and GND.
- Verify the sensor is outputting LOW when the beam is interrupted.
3. IR Receiver Not Detecting Beam?
- Ensure the IR LED is working (test with a camera to see infrared light).
- Use a TSOP1738 module if detecting modulated IR signals.
CONCLUSION
The Infrared Light Barrier Alarm provides a simple and effective way to detect intrusions or object interruptions. Using an IR transmitter and receiver, it triggers an alarm when the beam is broken. This system can be used for security, automation, or access control. It can be enhanced by adding a relay for external devices or integrating GSM/Wi-Fi for remote alerts.