Smart Corridor Light System: Arduino & PIR Sensor

Model Picture

 1. Introduction

Energy conservation is a key part of modern smart homes. In this project, we build a Smart Corridor Light System that automatically turns on when it detects human motion and turns off after a set delay. This is perfect for hallways, staircases, or bathrooms, ensuring lights are never left on accidentally.

2. Components

  • Arduino Uno or Nano

  • PIR Motion Sensor (HC-SR501)

  • 5V Relay Module (to control AC lights)

  • LDR (Photoresistor)Optional, to ensure lights only turn on at night

  • LED (Status Indicator)

  • 10kΩ Resistor

  • Jumper Wires and Breadboard

3. Circuit and Connections

Pinout Diagram of Arduino Uno R3
Pinout Diagram of Arduino Uno R3

Pinout Diagram of PIR Motion Sensor
Pinout Diagram of PIR Motion Sensor
Pinout Diagram of Single Channel Relay Module
Pinout Diagram of Single Channel Relay Module




LDR
LDR Diagram

  • PIR Sensor: VCC → 5V, GND → GND, OUT → Digital Pin 2

  • Relay Module: VCC → 5V, GND → GND, IN → Digital Pin 8

  • LDR (Optional): One side → 5V, Other side → Analog Pin A0 (with 10k resistor to GND)

  • Status LED: Anode → 220Ω Resistor → Digital Pin 13, Cathode → GND

4. Detailed Step-by-Step Circuit Working

  1. Motion Detection: The PIR sensor detects infrared radiation from human body heat. When someone walks by, the OUT pin goes HIGH.

  2. Light Sensing (Logic): If you include the LDR, the Arduino checks the light level. If it's already bright (daytime), it ignores the PIR signal to save even more power.

  3. Switching: The Arduino sends a signal to the Relay (Pin 8).

  4. AC Control: The Relay acts as a heavy-duty switch, connecting the live wire of your home bulb to the power source.

  5. Timer: The Arduino keeps the relay active for a specific duration (e.g., 30 seconds) before turning it off.

5. Libraries to be included

This project uses standard Digital and Analog I/O. No external libraries are required, making the system extremely reliable.

6. Code

C++
const int pirPin = 2;
const int relayPin = 8;
const int ldrPin = A0;
const int lightThreshold = 400; // Adjust for your room's darkness

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH); // Relay Off (Active Low)
  Serial.begin(9600);
}

void loop() {
  int motion = digitalRead(pirPin);
  int lightLevel = analogRead(ldrPin);

  if (motion == HIGH && lightLevel < lightThreshold) {
    Serial.println("Motion Detected at Night! Turning on Light.");
    digitalWrite(relayPin, LOW); // Turn Light ON
    delay(30000);                // Keep on for 30 seconds
    digitalWrite(relayPin, HIGH); // Turn Light OFF
  }
}

7. Detailed Step-by-Step Code Working

  1. digitalRead(pirPin): Constantly monitors for high signals from the motion sensor.

  2. Dual Condition (&&): The code only triggers the relay if both motion is detected AND the room is dark.

  3. Active Low Relay: Most 5V relays turn ON when the pin is LOW, so we set it to HIGH in the setup to keep the light off initially.

  4. Non-Blocking Delay: While delay(30000) works for a simple setup, you can mention "Millis()" in your tips for more advanced users.

8. Tips

  • Sensitivity Adjustment: Use the orange potentiometers on the PIR sensor to adjust the "Delay Time" and "Distance."

  • Safety First: Always remind readers to be extremely careful when working with AC High Voltage (230V). Suggest using a DC lamp for testing first.

  • LDR Placement: Ensure the LDR is not directly under the bulb it controls, or it will create a "flicker loop."

9. Uses

  • Smart Homes: Automatic lighting for corridors and porches.

  • Security: Use it as a motion-activated floodlight for your garage.

  • Energy Saving: Ideal for office cabins or public restrooms.

10. Conclusion

The Smart Corridor Light System is a perfect entry-point into home automation. It combines environmental sensing with power electronics to create a project that is both useful and environmentally friendly.


Similar Posts you May Be Interested:

https://simplebasicelectronics.blogspot.com/2 026/03/arduino-pir-motion-sensor-alarm.html

https://simplebasicelectronics.blogspot.com/2026/03/arduino-gas-leak-detector-using-mq-2.html

https://simplebasicelectronics.blogspot.com/2026/03/arduino-flame-sensor-fire-alarm.html

https://simplebasicelectronics.blogspot.com/2026/04/arduino-driver-drowsiness-detection.html

https://simplebasicelectronics.blogspot.com/2026/03/diy-arduino-rain-alarm-yl83.html

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.