forked from yorkhackspace/SpacehackClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpiotest.py
32 lines (30 loc) · 865 Bytes
/
gpiotest.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
#import Adafruit_BBIO.GPIO as GPIO
from controls import sh_gpio as GPIO
GPIO.init_smbus(1)
Run = True
while (Run):
pin = raw_input("Enter pin name or 'q' to exit or 'a' to attach expander: ")
InPin = True
if pin == "q":
Run = False
elif pin == "a":
exp = raw_input("enter expander number: ")
GPIO.attach_expander(int(exp))
else:
while InPin:
Command = raw_input("Select command; i-Input, o-Output, r-Read, 1-Set high, 0-Set low, b-Back, p-Poll: ")
if Command == "i":
GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN)
elif Command == "o":
GPIO.setup(pin, GPIO.OUT)
elif Command == "r":
print GPIO.input(pin)
elif Command == "1":
GPIO.output(pin, GPIO.HIGH)
elif Command == "0":
GPIO.output(pin, GPIO.LOW)
elif Command == "b":
InPin = False
elif Command == "p":
while True:
print GPIO.input(pin)