mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Makes it much easier to test things - no copying'n'pasting just run the examples straight from the dir (after wiring stuff up)
16 lines
230 B
Python
16 lines
230 B
Python
from gpiozero import Button
|
|
from signal import pause
|
|
|
|
def say_hello():
|
|
print("Hello!")
|
|
|
|
def say_goodbye():
|
|
print("Goodbye!")
|
|
|
|
button = Button(2)
|
|
|
|
button.when_pressed = say_hello
|
|
button.when_released = say_goodbye
|
|
|
|
pause()
|