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.