instructables
Ideal Automatic Lighting System Using Arduino + LDR + PIR
by Smart Technology
In this project,We will set up an automatic lighting The main purpose of this project is to prevent loss of
system using arduino, so the ideas came when I tried current unnecessarily during day time and make the
to build automatic lighting system using arduino and system more efficient then before.
PIR motion sensor but I confronted big issue because
the light turn ON even if daytime,this is why I thought
to use LDR in order to solve this issue.
Ideal Automatic Lighting System Using Arduino + LDR + PIR: Page 1
Step 1: Hardware/Software Supplies
Hardware Supplies:
1. Arduino Uno ( any other arduino board will be just fine as long as it provides an Analogical pin ).
2. PIR Motion Sensor
3. LDR (Photoresistor)
4. 10 KOhms resistor
5. Relay module
6. Lamp
7. Breadboard (optional)
Software Supplies:
1. Arduino IDE
Ideal Automatic Lighting System Using Arduino + LDR + PIR: Page 2
Step 2: Specifications of the Main Components
PIR sensor: LDR resistor:
The PIR sensor stands for Passive Infrared sensor. It A photoresistor (or light-dependent resistor, LDR,or
is a low cost sensor which can detect the presence of photo-conductive cell) is a light-controlled variable
Human beings or animals. There are two important resistor. The resistance of a photoresistor decreases
materials present in the sensor one is the pyroelectric with increasing incident light intensity.a photoresistor
crystal which can detect the heat signatures from a is made of a high resistance semiconductor. In the
living organism (humans/animals) and the other is a dark, a photoresistor can have a resistance as high
Fresnel lenses which can widen the range of the as several megohms (M ), while in the light,a
sensor. Also the PIR sensor modules provide us photoresistor can have a resistance as low as a few
some options to adjust the working of the sensor as hundred ohms.(Source : Wikipedia )
shown in above image.
Step 3: Circuit Assembly
To make the circuit assembly more easy I will 2.Connect the other LDR leg to the A4 pin Of Arduino
explained in Two parts : and also to the resistor
1. Arduino and LDR 3.Connect the (empty) resistor to the GND of the
The schematic is quite simple you should just follow Arduino.
the instructions bellow :
Note: You can see all the connections in the picture
1.Connect one of the LDR leg to the VCC (5v of the above.
Arduino).
relay can do this job, which is the sole design of it. so
we are using relay as switch to control high power
2. Arduino and PIR motion sensor devices.
The PIR sensor has three pins :
There are two ways to assembly the relay connection
1. VCC :
2. GND 1. NC = Normally Closed Connection ( which I'm
going to use ).
3. OUT
2. NO = Normally Open Connection.
We have powered the PIR sensor using he 5V Rail of
the Arduino. The output pin of the PIR Sensor is so you have to wire the relay's ''OUT'' to the 8th
connected to the 8thdigital pin.Then, you have to wire digital pin of the arduino uno.
the ''GND'' to the Arduino's ''GND''.
Then the relay's ''GND'' to the arduino's ''GND'' and
In this project, we use relay for controlling AC light ''VCC'' to the ''VCC''.
because the Arduino cannot control high volt , but a
Ideal Automatic Lighting System Using Arduino + LDR + PIR: Page 3
Ideal Automatic Lighting System Using Arduino + LDR + PIR: Page 4
Step 4: Watch the Video for More Details
https://youtu.be/UDEQ-l4gdAU
Ideal Automatic Lighting System Using Arduino + LDR + PIR: Page 5
Step 5: Arduino Code
About the code :
#define LAMP 8 // choose the pin for the RELAY
#define PIR 13 // choose the input pin (for PIR sensor)
void setup()
Serial.begin(9600);
pinMode(LAMP, OUTPUT); // declare lamp as output
pinMode(PIR,INPUT); // declare sensor as input
void loop() {
int valeur_ldr = analogRead(A4); // read LDR value
int valeur_pir = digitalRead(PIR); // read input value
Serial.println(valeur_ldr);
Serial.println(valeur_pir);
if((300>valeur_ldr) && ( valeur_pir==HIGH) ){
digitalWrite(LAMP,1); // Turn ON the light
delay(6000);
}
else {
digitalWrite(LAMP,0); // Turn OFF the light
}
}
Ideal Automatic Lighting System Using Arduino + LDR + PIR: Page 6
Ideal Automatic Lighting System Using Arduino + LDR + PIR: Page 7