-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRpi_execution.py
More file actions
executable file
·60 lines (55 loc) · 1.26 KB
/
Rpi_execution.py
File metadata and controls
executable file
·60 lines (55 loc) · 1.26 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import smbus
from recognize import *
GPIO.setmode(GPIO.BCM)
GPIO.setup(16,GPIO.OUT) #buzzer
GPIO.setup(22,GPIO.OUT) #relay switch
GPIO.setup(18,GPIO.IN,pull_up_down=GPIO.PUD_UP) #IR sensor signal
bus=smbus.SMBus(1)
address=0x04
cmd={'b':0,'w':1,'s':2,'d':3,'a':4,'x':-1}
class Status:
def __init__(self):
self.CAMERA=False
self.child_process=init()
def interruptHandler_IR(self):
self.CAMERA=True
def init_child_process(self):
self.child_process=init()
S=Status()
def writeCMD(value):
bus.write_byte(address,value)
def IR_callback(channel):
S.interruptHandler_IR()
GPIO.output(22,True)
shot()
GPIO.output(22,False)
if recognize(S.child_process):
GPIO.output(16,True)
while True:
GPIO.output(22,False)
time.sleep(0.1)
GPIO.output(22,True)
time.sleep(0.1)
else:
GPIO.output(22,False)
S.init_child_process()
S.CAMERA=False
GPIO.add_event_detect(18,GPIO.RISING,callback=IR_callback)
if __name__=="__main__":
f=open("seq.txt",'r')
line=f.readline()
currentline=line.split(",")
GPIO.output(16,False)
GPIO.output(22,False)
while True:
for key in currentline:
while(S.CAMERA):
a=1
writeCMD(cmd[key])
time.sleep(1.1)
GPIO.output(16,False)
GPIO.output(22,False)
f.close()