Introduction: Arduino - LDR With LED

This is simple arduino project; turn on LED when it's dark and turn off when is light.

Step 1: Hardware Required :

Picture of Hardware Required :

  • Arduino Uno
  • LED
  • LDR (photoresistor)
  • 220 and 10k ohm resistors
  • Wires
  • Breadboard

Step 2: LED Connection

Picture of LED Connection

  1. LED attach to board
  2. Resistor (220 ohm) one leg attach to LED long leg
  3. The green wire attach to resistor's empty leg
  4. The brown wire attach o LED short leg

Step 3: LDR Connection

Picture of LDR Connection

  1. LDR attach to board
  2. Resistor (10k ohm) attach to LDR one leg
  3. The purple wire attach to LDR other (empty) leg
  4. The yellow wire attach to LDR and resistor same column
  5. The white wire attach to resistor empty leg

Step 4: Arduino Connections

Picture of Arduino Connections

  1. The green wire connect to digital 13 from resistor leg
  2. The brown wire connect to GND from LED short leg
  3. The purple wire connect to +5V from LDR
  4. The yellow wire connect to A0
  5. The white wire connect to GND

Step 5: Code

Picture of Code

const int ledPin = 13;

const int ldrPin = A0;

void setup() {


pinMode(ledPin, OUTPUT);

pinMode(ldrPin, INPUT);


void loop() {

int ldrStatus = analogRead(ldrPin);

if (ldrStatus <=300) {

digitalWrite(ledPin, HIGH);

Serial.println("LDR is DARK, LED is ON");


else {

digitalWrite(ledPin, LOW);




Step 6: If It Helps, Please Subscribe

Picture of If It Helps, Please Subscribe

First of all, I would like to thank you for reading this guide ! I hope it helps you.

If you want to support me, you can subscribe my channel and watch my videos.

Mert Arduino Tutorial & Projects


paualex made it! (author)2017-09-09

Well explained

NaifA made it! (author)2017-05-19

i finally did it. thanks a lot for your easy explanation

fcfelix (author)2016-11-17

This is a very nice tutorial if you want to extend the circuit to more complex functions afterwards. Will for sure be useful to many tinkers. For a basic circuit like this no Arduino is needed, there are instructables on this.

About This Instructable




Bio: For more project and tutorial visit my YouTube channel Mert Arduino and Raspberry Pi
More by MertArduino:Arduino - Balance - Balancing Robot | How to Make?Arduino - MPU6050 GY521 - 6 Axis Accelerometer + Gyro (3D Simulation With Processing)NodeMCU ESP8266 - WiFi Robot Car Controlled by Application (Wifi Bot / Android / IoT)
Add instructable to: