Getting LED Lights ON/OFF In Arduino When Light Intensity Changes


This article is for developers interested in the Internet of Things. I'll describe an Arduino project with automated lights that turn ON/OFF with a weather change as per the light intensity in LDR.
  1. Arduino Uno
  2. Arduino Software
  3. One LED light “5MM”
  4. 300 Ohm resister (2)
  5. Jumper wire only five (Male to Male)
  6. Bread broad
  7. LDR (Light Dependent Resistor)
Steps to follow,
Step 1
First, connect the Arduino with the laptop or computer. Light blinks in the Arduino board.
Step 2
If you don’t have Arduino software take a look at this website
Then after the installation process is complete, this page will appear on your screen
Step 3
Then Click TOOL- Select BOARD - Then press ARDUINO/GENUINO UNO R3
Again Select TOOL - Select a PORT- COM3 ARDUINO UNO
Step 4
I have given a source code you can use this or you can use your own source code.
Source Code 
  1. constintledPin = 13;  
  2. constintldrPin = A0;  
  3. void setup() {  
  4.     Serial.begin(9600);  
  5.     pinMode(ledPin, OUTPUT); //initialize the LED pin as an output  
  6.     pinMode(ldrPin, INPUT);  
  7. }  
  8. void loop() {  
  9.     intldrStatus = analogRead(ldrPin); //read the status of the LDR value  
  10.     if (ldrStatus <= 200) -- - {  
  11.         digitalWrite(ledPin, HIGH);  
  12.         Serial.println("LDR is DARK, LED and BUZZER is ON");  
  13.     }  
  14.     else {  
  15.         digitalWrite(ledPin, LOW); //turn LED off  
  16.         Serial.println("---------------");  
  17.     }  
  18. }   
Step 5
Then click the verify button, to verify the program coding.
Automatic lights on and off Circuit diagram using LDR with the weather change.
Then click this button to upload.
When lights in my room are on the light in the bread broad is also off
These are the comments found in the dashboard of Arduino Software when Light in the breadboard is Off
When Room Lights are OFF, LDR sensor resistance becomes very high and with the help of our program Lights in the Breadboard turns ON.
These are the comments found in the dashboard of the Arduino Software when the light in the breadboard is On.
Weather change LDR resistance changes. The LED glows when light intensity is less and turns OFF when light intensity is high. This program is very simple to handle.


An Arduino project with Automated lights ON/OFF with Weather change is hence created and executed.
Very exciting articles are coming up next.