Raspberry Pi practice problem · Buttons & input
Ready, set, go
EasyBudget $3Python · gpiozero
Not every program needs callbacks: sometimes it should simply wait for a person.
A button on GPIO27 (to ground) and an LED on GPIO17. The program:
- prints
Waiting...straight away - waits until the button is pressed
- prints
Go!once and switches the LED on for good
Later presses change nothing. The test presses the button at 2.0 s and again at 3.5 s.
Tip: gpiozero's button.wait_for_press() blocks until the press.