mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Convert recipe examples to includes
Makes it much easier to test things - no copying'n'pasting just run the examples straight from the dir (after wiring stuff up)
This commit is contained in:
23
docs/examples/all_on_3.py
Normal file
23
docs/examples/all_on_3.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from gpiozero import LED, Buzzer, Button
|
||||
from signal import pause
|
||||
|
||||
button = Button(2)
|
||||
buzzer = Buzzer(3)
|
||||
red = LED(4)
|
||||
amber = LED(5)
|
||||
green = LED(6)
|
||||
|
||||
things = [red, amber, green, buzzer]
|
||||
|
||||
def things_on():
|
||||
for thing in things:
|
||||
thing.on()
|
||||
|
||||
def things_off():
|
||||
for thing in things:
|
||||
thing.off()
|
||||
|
||||
button.when_pressed = things_on
|
||||
button.when_released = things_off
|
||||
|
||||
pause()
|
||||
Reference in New Issue
Block a user