Arduino with LDR Project Using LED and Relay

Arduino with LDR Project Using LED and Relay

This project shows you how to automatically turn ON and OFF a Light using an Arduino with LDR or Light Dependent Resistor.

Dark is not really cool. Do you want to eliminate the darkness automatically? With this simple project, you can eliminate the darkness. You can also use this as an automatic on-off street light and an emergency lighting system.

Components Required  for the Arduino with LDR Project

Arduino Uno× 1Amazon
LDR× 1Amazon
LED and Resistor Kit× 1Amazon
5V Relay Module× 1Amazon
Breadboard× 1Amazon
Jumper wires× 2Amazon
USB cable type A/B× 1Amazon

Disclosure: These are affiliate links. As an Amazon Associate, I earn from qualifying purchases.


Arduino IDE


LDRs are light-dependent instruments, whose resistance decreases when light falls on them and increases in darkness. When a light dependent resistor is kept dark, it has very high resistance. It can be as high as 4.5 Ω. If the device can absorb light, its resistance is dramatically reduced. The current increases when a constant voltage is applied and the light intensity increased. The following figure shows the resistance vs. illumination curve for a particular LDR.


  • Wide spectral response
  • Wide ambient temperature range
  • Low cost 

LDR Specifications

Voltage100V AC or DC
Operating temperature range-25°C +75°C
Min. resistance @ 10lux1.8kΩ
Max. resistance @ 10lux4.5kΩ
Dark resistance after 1 sec0.03MΩ
Dark resistance after 5 sec0.25MΩ
Cost Check Price

Analog Application of LDR

  1. Modulated light source Automated gain control
  2. Colorimetric Test Equipment
  3. Densitometric measurement
  4. Dual cell electronic scales
  5. Rear view automatic mirror
  6. Automatic Gain Control – modulated light source
  7. Exposure Control Camera
  8. Dual cell Auto-Slide Focus
  9. Photocopy Machines – toner density

Digital Applications of LDR

  1. Night Light Control
  2. Street Light Control
  3. Automatic Headlight Dimmer
  4. Oil Burner Flame Out

For more information, you can check out the LDR Datasheet below:

Arduino with LDR Project Using LED Schematics

Arduino with LDR Project Using LED Schematics
Arduino with LDR Project Using LED Schematics

LDR connected to analog pin A0. In series with 10K resistor another end of the resistor will go to GND. LED connected from digital pin 2 to ground through a 220ohm resistor.

Arduino with LDR Project Using Relay Schematics

Arduino with LDR Project Using Relay Schematics
Arduino with LDR Project Using Relay Schematics

A bulb connects with a 5V relay module’s NO pin and NC pin. 

warning signWaring
This board interfaces with a high-voltage AC supply.   Improper or incorrect use may result in serious injury or death. As a result, it is intended for people who are familiar with and knowledgeable about HIGH AC voltage.

Arduino with LDR Project Code

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

int LDRInput=A0; //Set Analog Input A0 for LDR.
int LED=2;
void setup() {

void loop() {
int value=analogRead(LDRInput);//Reads the Value of LDR(light).
Serial.println("LDR value is :");//Prints the value of LDR to Serial Monitor.
    digitalWrite(LED,HIGH);//The LED turns ON in Dark.
    digitalWrite(LED,LOW);//The LED turns OFF in Light.


 You should see your LED turn ON in dark, and OFF in light. If you cannot see the desired output, ensure the circuit has been properly assembled, and verified and uploaded the code to your board.

  1. Make automated Street Light system that will ON during night and OFF during day.
  2. You can make your own home automation using LDR sensor.

Leave a Reply