-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
44 lines (41 loc) · 766 Bytes
/
test.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
import wimote
import cwiid
import time
import usonic
import led
import motor
import sys
Trigger_front = 8
Echo_front = 7
Collision=10
Led=11
def main():
wm=wimote.connect(Led)
while True:
button=wimote.whichbutton(wm)
time.sleep(0.05)
wm.rumble=False
#Moving Forwards
if button==3:
distance_front = usonic.reading(Trigger_front,Echo_front)
print distance_front
if distance_front < Collision:
wm.rumble=True
#led.off(Led)
motor.stop()
elif distance_front >= Collision:
#led.on(Led)
motor.forward()
#Reverse
if button==4:
motor.reverse()
if button==7:
motor.cleanup()
led.cleanup()
usonic.cleanup()
sys.exit()
if button==None:
led.off(Led)
motor.stop()
if __name__=="__main__":
main()