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

Introduction

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.

Requirements

  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.

IoT

Step 2

If you don’t have Arduino software take a look at this website

https://www.arduino.cc/en/Main/Software

IoT

Then after installation process is complete, this page will appear on your screen

IoT

Step 3

Then Click TOOL- Select BOARD - Then press ARDUINO/GENUINO UNO R3

Again Select TOOL - Select a PORT- COM3 ARDUINO UNO

IoT

Step 4

I have given a source code you can use this or you can use your own source code.

IoT

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 verify button, to verify the program coding.

IoT

Automatic lights on and off Circuit diagram using LDR with weather change.

IoT

Then click this button to upload.

IoT

When lights in my room are on the light in the bread broad is also off

IoT

These are the comments found in the dashboard of Arduino Software when Light in the breadbroad is Off

IoT

When Room Lights are OFF, LDR sensor resistance becomes very high and with the help of our program Lights in the Breadboard turns ON.

IoT

These are the comments found in the dashboard of the Arduino Software when light in the breadboad is On.

IoT

With 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.

Summary

An Arduino project with Automated lights ON/OFF with Weather change is hence created and executed.

Very exciting articles are coming up next.

Up Next
    Ebook Download
    View all
    Learn
    View all