Photoresistor (LDR)
Resistance falls as light rises — read it with a voltage divider.
How it works
A photoresistor (LDR, light-dependent resistor) changes resistance with light: high resistance (megohms) in the dark, low resistance (a few kΩ) in bright light. It isn't polarized.
A microcontroller can't read resistance directly, so pair the LDR with a fixed resistor (10 kΩ is a good start) to form a voltage divider, and read the midpoint with an analog pin. As the light changes, the midpoint voltage changes, and analogRead() follows it.
Pins
- Leg 1
- To +5V (one end of the divider).
- Leg 2
- To the analog pin AND to GND through a 10 kΩ resistor.
Ratings
- Dark resistance
- ~200 kΩ – 1 MΩ+
- Light resistance
- ~1–10 kΩ
- Divider resistor
- 10 kΩ to start
Tips
- With LDR to 5V and 10 kΩ to GND, the reading goes up in light, down in the dark.
- Print analogRead() to the Serial Monitor to pick a threshold for your room.