Project: Automated Home Lighting System (Light + Motion Based)

:magnifying_glass_tilted_left: Description:

This project creates a smart lighting system that automatically turns lights on when someone enters a room and adjusts brightness based on ambient light.

It’s energy-efficient, cost-effective, and perfect for rooms, corridors, or outdoor lighting.


:light_bulb: Improvements Over Basic Motion Detectors:

  • :white_check_mark: Dual control using both motion and light detection.
  • :white_check_mark: Prevents unnecessary lighting in daylight.
  • :white_check_mark: Expandable for multiple rooms/zones.
  • :white_check_mark: Can connect to relay-controlled bulbs or LED strips.

:toolbox: Required Components:

Component Quantity
Arduino Uno 1
PIR Motion Sensor 1
LDR (Light Sensor) 1
10kΩ Resistor (for LDR) 1
Relay Module (5V) 1
LED Bulb / Strip (220V or 12V) 1
Breadboard + Jumper Wires as needed
Power Supply 1

:electric_plug: Circuit Diagram (Explanation):

PIR Sensor:

  • VCC → 5V
  • GND → GND
  • OUT → Pin 2

LDR:

  • One leg → 5V
  • Other leg → A0
  • Same leg → 10kΩ → GND

Relay Module:

  • VCC → 5V
  • GND → GND
  • IN → Pin 3
  • Relay Output:
    • COM → Live wire of power source
    • NO → Bulb’s Live wire
    • Neutral → Direct to bulb

:warning: Caution: Use precautions while connecting AC bulbs. You may test with an LED and battery first.

:brain: Full Arduino Code:

int pirPin = 2;
int ldrPin = A0;
int relayPin = 3;

int lightThreshold = 500; // Tune this as per your environment

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(relayPin, OUTPUT);
  Serial.begin(9600);
}

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

  Serial.print("Motion: "); Serial.println(motion);
  Serial.print("Light Level: "); Serial.println(lightLevel);

  if (motion == HIGH && lightLevel < lightThreshold) {
    digitalWrite(relayPin, HIGH);  // Turn ON light
    Serial.println("Motion detected & dark — Light ON");
  } else {
    digitalWrite(relayPin, LOW);   // Turn OFF light
    Serial.println("No motion or bright — Light OFF");
  }

  delay(1000); // Wait before next reading
}

:white_check_mark: How It Works:

  • The PIR sensor detects human motion.
  • The LDR checks whether the room is dark.
  • If it’s dark and motion is detected → Light turns ON.
  • Otherwise → Light stays OFF.

:gear: Future Upgrades (Optional Ideas):

  • Add Blynk IoT support to control remotely.
  • Add real-time clock for time-based lighting.
  • Use ultrasonic sensor instead of PIR for directional detection.

Useless without a schematic

AI needs more education.