-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmainCode.py
66 lines (60 loc) · 1.19 KB
/
mainCode.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
60
61
62
63
64
65
66
from Raveen.motorRotating import *
import tty, sys, termios
filedescriptors = termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin)
x = 0
duty = 40
while True:
# goForward(40)
# sleep(2)
# goLeft(40)
# sleep(2)
# goBackword(40)
# sleep(2)
# goRight(40)
# sleep(2)
x=sys.stdin.read(1)[0]
print("You pressed", x)
if x == "8":
goForward(duty)
sleep(1)
stop()
elif x == "2":
goBackward(duty)
sleep(1)
stop()
elif x == "4":
goLeft(duty)
sleep(1)
stop()
elif x == "6":
goRight(duty)
sleep(1)
stop()
elif x == "+":
turnRight(duty)
sleep(0.5)
stop()
elif x == "-":
turnLeft(duty)
sleep(0.5)
stop()
elif x == "9":
frontRight(duty)
sleep(0.5)
stop()
elif x == "1":
backLeft(duty)
sleep(0.5)
stop()
elif x == "7":
frontLeft(duty)
sleep(0.5)
stop()
elif x == "3":
backRight(duty)
sleep(0.5)
stop()
elif x == "r":
break
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, filedescriptors)