mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
19 lines
303 B
Python
19 lines
303 B
Python
from RPi import GPIO
|
|
|
|
|
|
GPIO.setmode(GPIO.BCM)
|
|
GPIO.setwarnings(False)
|
|
|
|
|
|
class InputDevice(object):
|
|
def __init__(self, pin):
|
|
self.pin = pin
|
|
GPIO.setup(pin, GPIO.IN, GPIO.PUD_UP)
|
|
|
|
def is_pressed(self):
|
|
return GPIO.input(self.pin) == 0
|
|
|
|
|
|
class Button(InputDevice):
|
|
pass
|