Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
100 min
Share

Arduino Automatic Night Street Lights

Light Dependent Resistor (LDR) is essentially a photoresistor, which means its resistance is dependent on the amount of light it receives. We can use an LDR to detect the light level in the environment. If you are looking for an inexpensive solution to detect day and night, an LDR would be a good choice.

Project Video

Overview

In this tutorial, we will learn how to make a light sensor using an LDR with Arduino to control a bulb based on the light conditions of the room or outside area.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Photocell – LDR (4 pieces)
Get Item
Clear 5mm LED (5 pack)
Get Item
1/4 Watt Resistor (20 Pack)
Get Item
Half-size Breadboard
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wiresbetween the LDR and the Arduino and the led as shown in the image below.

Connections from the Arduino to the breadboard:

  • Arduino GND pin → Breadboard ground line

  • Arduino 5V pin → Breadboard 5V line

Connections from the LDR:

  • First pin → Breadboard 5V line

  • Second pin → 10KΩ resistor → Breadboard ground line

  • Common pin between LDR and the 10KΩ resistor → Arduino pin A0

Connections from the LED :

  • LED anode pin → Arduino pin 2

  • LED cathode pin → 330 ohm resistor first pin → Breadboard ground line

Coding

/*

Voltaat learn (http://learn.voltaat.com)

Link for full tutorial:

Tutorial: Arduino Automatic Night Street Lights!

The purpose of this sketch is to make the Arduino control the lighting of the lamp,

so that if the LDR sensor is placed in the dark,the led will light up, while if the

sensor is placed in light, the led will turn off.

Connections from the Arduino to the breadboard:

• Arduino GND pin → Breadboard ground line

• Arduino 5V pin → Breadboard 5V line

Connections from the LDR:

• First pin → Breadboard 5V line

• Second pin → 10KΩ resistor → Breadboard ground line

• Common pin between LDR and the 10KΩ resistor → Arduino pin A0

Connections from the LED :

• LED anode pin → Arduino pin 2

• LED cathode pin → 330 ohm resistor first pin → Breadboard ground line

*/

#define relay 10

int LED = 2;

int LDR = A0;

void setup()

{

Serial.begin(9600);

pinMode(LED, OUTPUT);

pinMode(relay, OUTPUT);

pinMode(LDR, INPUT);

}

void loop() {

int LDRValue = analogRead(LDR);

Serial.print("sensor = ");

Serial.print(LDRValue);

if (LDRValue <=700)

{

digitalWrite(LED, HIGH);

digitalWrite(relay, HIGH);

Serial.println("It's Dark Outside; Lights status: ON");

}

else

{

digitalWrite(LED, LOW);

digitalWrite(relay, LOW);

Serial.println("It's Bright Outside; Lights status: OFF");

}

}

Testing it Out

Once you’ve uploaded the code to the Arduino board,you will find that if the LDR sensor is placed in the dark, the led will lightup, while if the sensor is placed in light, the led will turn off.:

Resources

No items found.