Project tutorial
The PerfectAutomatic Lighting System Using Arduino + LDR ...

The PerfectAutomatic Lighting System Using Arduino + LDR ... © CC BY-NC-SA

The main purpose of this project is to prevent loss of current unnecessarily during day time and make the system more efficient then.

  • 9,214 views
  • 1 comment
  • 14 respects

Components and supplies

Apps and online services

About this project

In this project,We will set up an automatic lighting system using arduino, so the ideas came when I tried to build automatic lighting system using arduino and 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.

The main purpose of this project is to prevent loss of current unnecessarily during day time and make the system more efficient then before.

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

Step 2: Specifications of the Main Components

PIR sensor:

The PIR sensor stands for Passive Infrared sensor. It is a low cost sensor which can detect the presence of Human beings or animals. There are two important materials present in the sensor one is the pyroelectric crystal which can detect the heat signatures from a living organism (humans/animals) and the other is a Fresnel lenses which can widen the range of the sensor. Also the PIR sensor modules provide us some options to adjust the working of the sensor as shown in above image.

LDR resistor:

A photoresistor (or light-dependent resistor, LDR,or photo-conductive cell) is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity.a photoresistor is made of a high resistance semiconductor. In the dark, a photoresistor can have a resistance as high as several megohms (MΩ), while in the light,a photoresistor can have a resistance as low as a few hundred ohms.(Source : Wikipedia )

Step 3: Watch the Video for More Details

Step 4: Circuit Assembly

To make the circuit assembly more easy I will explained in Two parts :

1. Arduino and LDR

The schematic is quite simple you should just follow the instructions bellow :

1.Connect one of the LDR leg to the VCC (5v of the Arduino).

2.Connect the other LDR leg to the A4 pin Of Arduino and also to the resistor

3.Connect the (empty) resistor to the GND of the Arduino.

Note: You can see all the connections in the picture above.

2. Arduino and PIR motion sensor

The PIR sensor has three pins :

1. VCC

2. GND

3. OUT

We have powered the PIR sensor using he 5V Rail of the Arduino. The output pin of the PIR Sensor is connected to the 8thdigital pin.Then, you have to wire the ''GND'' to the Arduino's ''GND''.

In this project, we use relay for controlling AC light because the Arduino cannot control high volt , but a relay can do this job, which is the sole design of it. so we are using relay as switch to control high power devices.

There are two ways to assembly the relay connection :

1. NC = Normally Closed Connection ( which I'm going to use ).

2. NO = Normally Open Connection.

so you have to wire the relay's ''OUT'' to the 8th digital pin of the arduino uno.

Then the relay's ''GND'' to the arduino's ''GND'' and ''VCC'' to the ''VCC''.

Step 5: Arduino Code

About the code :

<p>#define LAMP  8  // choose the pin for the RELAY</p><p>#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
       
}
 }

Code

Code snippet #1Plain text
<p>#define LAMP  8  // choose the pin for the RELAY</p><p>#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
       
}
 }

Comments

Similar projects you might like

Control your light system with your voice

Project tutorial by Maha Raafat

  • 42,030 views
  • 22 comments
  • 160 respects

SMART Home LED Lighting System and More

Project in progress by Joey Pongallo

  • 8,180 views
  • 6 comments
  • 19 respects

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 49,266 views
  • 22 comments
  • 141 respects

Intrusion Alert System using Arduino and Bolt IoT

Project tutorial by Rohit Kumar

  • 2,841 views
  • 0 comments
  • 14 respects

Close Loop Control System Demo Using LED Light and LDR

Project tutorial by ambhatt

  • 766 views
  • 1 comment
  • 3 respects

Automatic Plant Watering System with Arduino

Project tutorial by Team RobotGeek Projects Team

  • 45,761 views
  • 4 comments
  • 83 respects
Add projectSign up / Login