bathroom-timer/button.py
Vincent Batts b10dcbba57
*: initial toying with gpiozero python3
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2024-11-15 21:08:19 -05:00

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)