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.
Improvements Over Basic Motion Detectors:
Dual control using both motion and light detection.
Prevents unnecessary lighting in daylight.
Expandable for multiple rooms/zones.
Can connect to relay-controlled bulbs or LED strips.
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 |
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
Caution: Use precautions while connecting AC bulbs. You may test with an LED and battery first.
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
}
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.
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.