-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPIO.py
43 lines (32 loc) · 960 Bytes
/
GPIO.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import RPi.GPIO as GPIO
from time import sleep as wait
class LED:
def __init__(self, port):
self.pin = port
#GPIO.setmode(GPIO.BOARD)
GPIO.setup(self.pin, GPIO.OUT)
self.ON = False
self.OFF = True
def turnOn(self):
GPIO.output(self.pin, self.ON)
def turnOff(self):
GPIO.output(self.pin, self.OFF)
def cleanup(self):
GPIO.cleanup(self.pin)
def getPin(self):
return self.pin
class Button:
def __init__(self, port):
self.pin = port
#GPIO.setmode(GPIO.BOARD)
GPIO.setup(self.pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def isPressed(self):
return not GPIO.input(self.pin)
def cleanup(self):
GPIO.cleanup(self.pin)
def getPin(self):
return self.pin
def waitUntilNotPressed(self):
while self.isPressed():
pass
wait(0.005)