Arduino - LDR With LED

by MertArduino in Circuits > Arduino

115233 Views, 89 Favorites, 0 Comments

Arduino - LDR With LED

Arduino Basic Tutorial 07 - LDR with LED

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

Hardware Required :

vlcsnap-2016-11-16-04h12m07s685.png

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

LED Connection

vlcsnap-2016-11-16-04h12m22s788.png
vlcsnap-2016-11-16-04h12m44s993.png
vlcsnap-2016-11-16-04h12m55s309.png
vlcsnap-2016-11-16-04h13m07s191.png

  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

LDR Connection

vlcsnap-2016-11-16-04h13m25s154.png
vlcsnap-2016-11-16-04h13m46s347.png
vlcsnap-2016-11-16-04h14m00s865.png
vlcsnap-2016-11-16-04h14m12s385.png
vlcsnap-2016-11-16-04h14m38s282.png

  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

Arduino Connections

vlcsnap-2016-11-16-04h15m24s969.png
vlcsnap-2016-11-16-04h15m37s126.png
vlcsnap-2016-11-16-04h15m47s200.png
vlcsnap-2016-11-16-04h16m11s991.png
vlcsnap-2016-11-16-04h16m29s027.png
vlcsnap-2016-11-16-04h16m44s803.png
vlcsnap-2016-11-16-04h17m10s507.png

  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

Code

vlcsnap-2016-11-16-04h17m51s270.png

const int ledPin = 13;

const int ldrPin = A0;

void setup() {

Serial.begin(9600);

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);

Serial.println("---------------");

}

}

If It Helps, Please Subscribe

vlcsnap-2016-11-16-04h18m01s593.png

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