Raspberry Pi practice problem · Buttons & input
Blink or steady
EasyBudget $4Python · gpiozero
A slide switch as a mode selector. Its common pin goes to GPIO27, pin 1 to ground and pin 2 to 3.3 V, so GPIO27 reads low with the lever left (where it starts) and high with it right.
An LED on GPIO17:
- lever left: the LED is steadily on
- lever right: the LED blinks, 0.25 s on, 0.25 s off
Read the switch continuously — it can change at any time. The test slides it right at 2 s and back left at 5 s.