-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrobocardirection.py
60 lines (34 loc) · 1.11 KB
/
robocardirection.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import RPi.GPIO as io
io.setwarnings(False)
io.setmode(io.BOARD)
Motor_INPUT1 = 3
Motor_INPUT2 = 5
Port1 = 7 #L293D First Input
Port2 = 8 #L293D Second Input
Port3 = 10 #L293D Third Input
Port4 = 11 #L293D Fourth Input
io.setup(Motor_INPUT1,io.IN)
io.setup(Motor_INPUT2,io.IN)
io.setup(Port1,io.OUT)
io.setup(Port2,io.OUT)
io.setup(Port3,io.OUT)
io.setup(Port4,io.OUT)
while True:
c = io.input(Motor_INPUT1)
d = io.input(Motor_INPUT2)
print c
print d
if c==0 and d==1:
io.output(Port1,True)
io.output(Port2,False)
io.output(Port3,False)
io.output(Port4,False)
print 'cd',c ,d
print 'Right'
if c==1 and d==0:
io.output(Port1,False)
io.output(Port2,False)
io.output(Port3,True)
io.output(Port4,False)
print "cd", c ,d
print 'Left'