LDR 5516 experiment

This lesson shows you how to use Arduino LDR photosensitive device to realize a light-emitting diode switch that can automatically control with ambient brightness

This lesson shows you how to use Arduino LDR photosensitive device to realize a light-emitting diode switch that can automatically control with ambient brightness. When the ambient brightness is relatively dark, the LED will turn on automatically.When the ambient brightness is relatively bright, the LED goes out automatically.

Component Required:

  • 1 x Uno R3

  • 1 x 830 tie-points breadboard

  • 1 x Yellow LED

  • 1 x LDR 5516

  • 2 x resistances(330Ω)

  • 7 x M-M wire (Male to Male jumper wire)

Component Introduction

Photoresistor is a resistor which made of semiconductor material,and the conductance changes with luminance variation .The photoresistor can be manufactured with different figures and illuminated area based on this characteristic.Photoresistor is widely used in many industries, such as toys, lamps, camera, etc.

Connection Diagram:

Wiring schematic:

Physical wiring diagram:

Code:

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 <= 200) {
    digitalWrite(ledPin, HIGH);
    Serial.print("Its DARK, Turn on the LED : ");
    Serial.println(ldrStatus);
  } else {
    digitalWrite(ledPin, LOW);
    Serial.print("Its BRIGHT, Turn off the LED : ");
    Serial.println(ldrStatus);
  }
}

Last updated