PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Projects

Wardrobe light

EasyBudget $11Python · gpiozero

Build the light inside a wardrobe: a slide switch is the door sensor: COM to GPIO27, pin 1 to ground, pin 2 to 3.3 V (lever right = door open = GPIO27 high). A lamp is switched by a high-trigger relay on GPIO26.

The lamp is on while the door is open and off while it is closed. The test opens the door at 1 s, closes it at 3 s and opens it again at 4.5 s.

Watch the budget: the Relay + lamp kit costs $13, but a loose Relay("high") ($4) and Lamp() ($5) do the same job. Wire the lamp from 5 V through the relay's COM → NO contacts (see the relay page).

More in Projects