Automatic Light Controlling System


Description

     How you feel whenever a room gets dark,a light bulb automatically turns ON and eliminates the darkness? I think it is really cool. In this project we are going to turn ON an LED when the intensity of light is low and turn OFF when the intensity of light is high. Here It is done by using an LDR (Light Dependent Resistor) Module.The output of the LDR Module goes high in the presence of light and it becomes low in the absence of light. And here it is shown by using LED. Okey let's start.

Components Required

 1. Arduino UNO      * 1 
 2. LED     * 1 
 3. Resister(220 Ohm)  * 1 
 4. LDR Module * 1 
 5. Jumper Wires * 1 

Circuit Diagram
Program

const int ledPin = 13; 
const int ldrPin = A0;  
void setup() 
  { 
     Serial.begin(9600); 
     pinMode(ledPin,OUTPUT); 
     pinMode(ldrPin,INPUT); 
   } 
  
void loop( 
  { 
     int ldrStatus = analogRead(ldrPin); 
   
     if (ldrStatus <= 400)                                                               
    { 

      digitalWrite(ledPin,LOW); 
      Serial.print(" Its DARK, turn on the LED: "); 
      Serial.println(ldrStatus);  
     } 
  else 
    { 
      digitalWrite(ledPin,HIGH); 
      Serial.print(" Its BRIGHT, turn off the LED: "); 
      Serial.println(ldrStatus);  
    } 
}