Smart Technology
Published © CC BY-NC-SA

The PerfectAutomatic Lighting System Using Arduino + LDR ...

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

IntermediateFull instructions provided3 hours26,201
The PerfectAutomatic Lighting System Using Arduino + LDR ...

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LDR photoresistor
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
RobotGeek Relay
RobotGeek Relay
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Lamp
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code snippet #1

Plain 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
       
}
 }

Credits

Smart Technology

Smart Technology

7 projects • 46 followers
Graduate of a Professional License in Instrumentation and Biomedical Maintenance and a D.U.T in Electrical Engineering and Maintenance.

Comments