-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttons.py
executable file
·38 lines (30 loc) · 970 Bytes
/
buttons.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
#!/usr/bin/env python
import time
import RPi.GPIO as GPIO
import subprocess
def main():
# tell the GPIO module that we want to use the
# chip's pin numbering scheme
GPIO.setmode(GPIO.BCM)
# setup pin 25 as an output
GPIO.setup(17,GPIO.IN)
GPIO.setup(18,GPIO.IN)
while True:
if GPIO.input(17):
print "Vision Api activated"
try:
rc = subprocess.call("cd /home/pi/unblind && sh /home/pi/unblind/visionapi.sh && cd -", shell=True)
except OSError as e:
print( e )
print "button17 true"
if GPIO.input(18):
print "OCR Api activated"
try:
rc = subprocess.call("cd /home/pi/unblind && sh /home/pi/unblind/ocr.sh && cd -", shell=True)
except OSError as e:
print( e )
print "button18 true"
time.sleep(0.1)
GPIO.cleanup()
if __name__=="__main__":
main()