Light Detection: The LDR Sensor Complete Guide
The Light Dependent Resistor (LDR) is the unsung hero of home automation. Found in everything from garden solar lights to smartphone screens, it translates the brightness of its environment into a resistance value.

The Voltage Divider Mystery
The Arduino cannot measure "Resistance" directly; it can only measure "Voltage". To use an LDR, we must build a Voltage Divider Circuit:
- Connect the 5V line to the LDR.
- Connect the other leg of the LDR to an Analog Pin (A0) AND to a 10k-ohm resistor.
- Connect the other leg of the 10k resistor to Ground.
- The Magic: As light hits the LDR, its resistance drops. This causes the voltage at pin A0 to climb closer to 5V. In the dark, the resistance skyrockets, and the voltage drops to 0V.
Required Hardware
- Arduino Uno/Nano.
- The LDR (Photoresistor).
- 10k-ohm Fixed Resistor: Absolutely mandatory for the math to work.
- Jumper Wires and Breadboard.
- Optional: An LED to act as an automated output.
Practical Experiments
Rather than just saying "Dark", you can use the Serial.println() command to map exactly how dark it is. You can create software bands: Analog 0-200 = Pitch Black, 200-500 = Dim Room, 500-800 = Bright Office, 800+ = Direct Sunlight outdoors!