25 lines
377 B
Python
25 lines
377 B
Python
#!/usr/bin/env python3
|
|
|
|
from gpiozero import LED
|
|
from gpiozero import Button
|
|
from time import sleep
|
|
|
|
led = LED(25)
|
|
button = Button(21)
|
|
|
|
def pressed():
|
|
led.on()
|
|
print("button pressed. LED on")
|
|
|
|
def released():
|
|
led.off()
|
|
print("button released. LED off")
|
|
|
|
button.when_pressed = pressed
|
|
button.when_released = released
|
|
print("ready")
|
|
|
|
while True:
|
|
sleep(0.2)
|
|
|
|
|