-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_code.txt
97 lines (96 loc) · 4.97 KB
/
example_code.txt
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import serial
ser = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=0.5)
while True:
name_str = input('Run CMD:')
if name_str == 'a':
ser.write(serial.to_bytes([0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('Left')
elif name_str == 's':
ser.write(serial.to_bytes([0x00,0x00,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('Down')
elif name_str == 'd':
ser.write(serial.to_bytes([0x00,0x00,0x4F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('Right')
elif name_str == 'w':
ser.write(serial.to_bytes([0x00,0x00,0x52,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('UP')
elif name_str == 'e':
ser.write(serial.to_bytes([0x00,0x00,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('ESC')
elif name_str == 'f1':
ser.write(serial.to_bytes([0x00,0x00,0x3A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F1')
elif name_str == 'f2':
ser.write(serial.to_bytes([0x00,0x00,0x3B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F2')
elif name_str == 'f3':
ser.write(serial.to_bytes([0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F3')
elif name_str == 'f4':
ser.write(serial.to_bytes([0x00,0x00,0x3D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F4')
elif name_str == 'f5':
ser.write(serial.to_bytes([0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F5')
elif name_str == 'f6':
ser.write(serial.to_bytes([0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F6')
elif name_str == 'f7':
ser.write(serial.to_bytes([0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F7')
elif name_str == 'f8':
ser.write(serial.to_bytes([0x00,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F8')
elif name_str == 'f9':
ser.write(serial.to_bytes([0x00,0x00,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F9')
elif name_str == 'f10':
ser.write(serial.to_bytes([0x00,0x00,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F10')
elif name_str == 'f11':
ser.write(serial.to_bytes([0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F11')
elif name_str == 'f12':
ser.write(serial.to_bytes([0x00,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('F12')
elif name_str == 't':
ser.write(serial.to_bytes([0x00,0x00,0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('tab')
elif name_str == '+':
ser.write(serial.to_bytes([0x00,0x00,0x57,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('+')
elif name_str == '-':
ser.write(serial.to_bytes([0x00,0x00,0x56,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('-')
elif name_str == '1':
ser.write(serial.to_bytes([0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('1')
elif name_str == '2':
ser.write(serial.to_bytes([0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('2')
elif name_str == '3':
ser.write(serial.to_bytes([0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('3')
elif name_str == '4':
ser.write(serial.to_bytes([0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('4')
elif name_str == '5':
ser.write(serial.to_bytes([0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('5')
elif name_str == '6':
ser.write(serial.to_bytes([0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('6')
elif name_str == '7':
ser.write(serial.to_bytes([0x00,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('7')
elif name_str == '8':
ser.write(serial.to_bytes([0x00,0x00,0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('8')
elif name_str == '9':
ser.write(serial.to_bytes([0x00,0x00,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('9')
elif name_str == '0':
ser.write(serial.to_bytes([0x00,0x00,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]))
print('0')
else:
print('N/A')