A Light Dependent Resistor (LDR). An LDR, also known as a photoresistor, is a component whose resistance varies with the amount of light falling on it. These devices are made of semiconductor materials that allow them to change their resistance based on the light intensity.
In this tutorial, we will use the Arduino to read the resistance of an LDR and detect darkness. This project may be expanded to control an LED to turn on when the light goes out and off when it comes back, similar to how a street light works!
Connect the wires between the LDR and the Arduino, as shown in the image below.
Connections from the Arduino to the breadboard:
• Arduino pin GND → Breadboard ground line
• Arduino pin 5V → Breadboard 5V line
• Arduino pin A3 → Common pin between LDR and the 10KΩ resistor
Connections from the LDR:
• First pin→ Breadboard 5V line
• Second pin→ 10KΩ resistor left pin
• 10KΩ resistor right pin→ Breadboard ground line
After uploading the code, you can now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.
Now, as we see in the following image, the serial monitor displays the status of the light presence and the analog read value from the analog input A0.