08 35 minutes
Automatic nightlight
A light sensor, two thresholds, and a lamp that will not flicker

Mission goal: Replace the knob with a light-dependent resistor, calibrate your own thresholds, and build a lamp that switches on in the dark using hysteresis.
Section 1
Understand
New ideas
- An LDR as half of a voltage divider
- Calibrating with real measured readings
- Hysteresis: two thresholds instead of one
- Remembering the previous state
- 1A light sensor plus a 10 kΩ resistor makes a light-to-voltage divider.
- 2Two thresholds (LOW and HIGH) stop flicker at dusk.
- 3Between them, the lamp keeps whatever state it was in.
Safety first
- Unplug before removing the potentiometer and fitting the LDR.
- Use the bare two-leg LDR from the kit, not a sensor module with extra pins.
- Keep 3.3 V from physical pin 36. Do not use 5 V anywhere near a GPIO pin.