Introduction: Auotmatic Street Lights Control Using LDR and Arduino

Automatic street light control is used to control the street lights(Turn on and off based on the light).

Here we make use of LDR(Light Dependent Resistor) and LED(Light Emitting diode) and arduino.

Hard Ware Components Required:

1) LDR


3)4.7k Resistor

4)Bread Board

5)Connecting wires


LDR is used to detect the light, Arduino is used to on/off the Light.

For LDR Basics and Principles Please go through the below link.

For LED interfacing Please follow the below link.

Hardware Connections.-

Arduino 3rd pin connected to LED +ve

Arduino GND connected to LED -ve through 4.7k

Arduino +5v is connected to LDR One End

Arduino A0 pin is connected to LDR other end

Arduino GND is connected to LDR other end with 4.7k


Step 1: Programming, Compiling and Uploading to Arduino

// Program related to LDR and LED interfacing to Arduino

#include <SoftwareSerial.h>

int sensorPin = A0; // select the input pin for the LDR

int sensorValue = 0; // variable to store the value coming from the sensor

int led = 3;

void setup() { // declare the ledPin as an OUTPUT:

pinMode(led, OUTPUT);

Serial.begin(9600); }

void loop()


Serial.println("Welcome to TechPonder LDR Tutorial");

sensorValue = analogRead(sensorPin);


if (sensorValue < 100)


Serial.println("LED light on");







Copy and Paste the code in arduino new sketch folder later compile and upload the program as show in the images.

Please click on serial window, which is located top right corner of the Arduino IDE to view the results.

Step 2: Results

Results are displayed on the serial window.

When there is low amount of light the light automatically glows and when there is sufficient amount of light it automatically turns off the light.

Here based on our room condition the threshold value we took is 100 for the LDR sensor.

When we place a hand on LDR(Not allowing any light on LDR) arduino automatically turns on the LED.

When we remove our hand on LDR. Arduino automatically Turns Off LED.