Menu Close

LDR – Automatic Night Lamp

This tutorial explains concept and how to make Automatic Night Lamp using LDR

1. Introduction:

A LDR (Light Dependent Resistor) or a photo resistor is a photo conductive sensor. It is a variable resistor and changes its resistance in a proportion to the light exposed to it. It resistance decreases with the intensity of light.

It senses the light intensity from surroundings and find whether its day or night then it automatically turns ON when the surrounding is dark and it turns OFF when it receives light from surroundings.

2. Required Hardware

Following Hardware will be required to perform this LDR circuit.

S.No.ItemQuantity
1 Arduino UNO 1
2 Breadboard 1
3 LDR 1
4 LED 1
5 Resistor 1k 1
6 Resistor 10k 1
7 Male to Male Jumper 7

3. Building Circuit

Make following circuit with the help of above mentioned components. Some key points to understand about the circuit-

LDR is connected to a 10 Resistance in series. +5 Voltage is applied to this arrangement. As the light intensity changes LDR value changes thus the voltage drop on LDR will change and we are going to measure that voltage change.

4. Programming:

Once we are done with circuit part, here is our programme to this circuit.

You may download this code (Arduino Sketch) from here.

//Robo India Tutorial on Night Lamp using LDR
//https://www.roboindia.com/tutorials

const int LED=2;            // LED connect to Digital Pin 
const int LDRSensor= A0;    //Sensor pin connects to analog pin A0

int state;                  //declaring variable to store the reading 
int threshold=600;          //threshold voltage declared 

void setup() 
{
  pinMode (LED, OUTPUT);   
  Serial.begin(9600); 
}

void loop()
{
  state= analogRead(LDRSensor); //sensor reading value stored in state variable
  if (state < threshold)
    {
      digitalWrite(LED, HIGH); //if the light is below the threshold value, the LED will turns on
      Serial.println(state);
      delay(2000);
    }
  else
    {
      digitalWrite(LED, LOW); //otherwise, the LED is off
      Serial.println(state);
      delay(1000);
    }
}

 5. Output:

Control the light exposing on LDR by covering it. If it gets dark, the LED connected will get turn ON automatically.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

Leave a Reply