Automatic Room Lights using Arduino
and PIR Sensor
In this project, we will see the Automatic Room Lights using Arduino and PIR
Sensor, where the lights in the room will automatically turn ON and OFF by detecting
the presence of a human.
Such Automatic Room Lights can be implemented in your garages, staircases,
bathrooms, etc. where we do not need continuous light but only when we are present
Also, with the help of an automatic room light control system, you need not worry
about electricity as the lights get automatically off when there is no person.
So, in this DIY project, we have implemented Automatic Room Lights using Arduino
and PIR Sensor.
Circuit Diagram of Automatic Room Lights using
Arduino
The following image shows the circuit diagram of the project implemented using
Arduino UNO, PIR Sensor and a Relay Module.
Components Required for Automatic Room Lights using
Arduino
Arduino UNO
PIR Sensor
5V Relay Module (Relay Board)
LED
100Ω Resistor (1/4 Watt)
Connecting Wires
Breadboard
Power Supply
Code
int in1 = 9;
int sensor = 8;
int led = 13;
unsigned long t=0;
void setup() {
Serial.begin(9600);
pinMode(in1, OUTPUT);
pinMode(sensor, INPUT);
pinMode(led, OUTPUT);
digitalWrite(in1,HIGH);
digitalWrite (in1,LOW); Commented [U1]:
digitalWrite(led,LOW);
while(millis()<13000)
{
digitalWrite(led,HIGH);
delay(500);
digitalWrite(led,LOW);
delay(500);
digitalWrite(led,LOW);
void loop()
digitalWrite(in1,HIGH);
digitalWrite(led,LOW);
if(digitalRead(sensor)==HIGH)
t=millis();
while(millis()<(t+5000))
digitalWrite(in1,LOW);
digitalWrite (led,HIGH);
If ((millis()>(t+2300)) &&(digitalRead(sensor)==HIGH))
t=millis();
}
}
Applications
I’ve already mentioned a few applications of the Automatic Room Lights concept.
Some of them are:
Garage Lights
Bathroom Lights
Hand Dryers
Toilet Flushers
Security Lights