# 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. 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.

![](/files/1BnsORNEtOXTK3zUkobT)

### **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.

![](/files/bATlK8KIjjamYBdg4Z7o)

### **Connection Diagram:**

![](/files/K5jcYlpxp5YXZl1K0kIF)

### **Wiring schematic:**

![](/files/wV7ojpE8XsAevnK9bU1u)

### **Physical wiring diagram:**

![](/files/8AvXgHyCkCq4l2aqKRVM)

### **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);
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.arduinosa.co.za/arduino-kits/basic-starter-kit/ldr-5516-experiment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
