Raspberry Pi practice problem · Sensors
Lights on, lights off
EasyBudget $8Python · gpiozero
An LDR on top of a 10 kΩ divider into channel 0 of an MCP3008 (or the light sensor + ADC board): brighter means a higher reading. Treat a reading above 0.5 as light. Print Lights on when it turns light and Lights off when it turns dark — only when it changes, never repeatedly and not at start-up.
The room starts dark, the lights go on at 2 s, off at 5 s and on again at 8 s. Read at least every 0.2 s.