Raspberry Pi Pico practice problem · Raspberry Pi Pico
Night light
MediumBudget $5MicroPython
An LDR and a 10 kΩ resistor make a divider on GP26: 3V3 → LDR → GP26 → 10 kΩ → GND. The brighter the light, the lower the LDR's resistance and the higher the ADC reading.
An LED on GP13 is the night light. Read the divider and:
- dark (low reading) → LED on
- light (high reading) → LED off
Check the reading every 50 ms or so. The test starts dark and turns the light on after a second and a half.