-
Notifications
You must be signed in to change notification settings - Fork 0
/
UART_master.py
81 lines (58 loc) · 1.6 KB
/
UART_master.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'''
Pins used:
Arduino 1 | Arduino 2 | BusPirate
D10 --> D1 --> MOSI
D11 --> D0 --> MISO
GND --> GND --> GND
'''
import time
import serial
from serial import Serial
ser = serial.Serial(port = 'COM9',baudrate = 115200,timeout=1)
ser.write(str('#' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('m' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('3' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('5' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('1' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('1' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('1' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('1' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.3)
ser.write(str('W' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('(0)' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.1)
ser.write(str('(2)' + '\n').encode('ascii'))
time.sleep(10)
ser.write(str('q' + '\n').encode('ascii'))
l = ser.readlines(1000)
print((str(l))[3::][:-6:])
ser.write(str('#' + '\n').encode('ascii'))
ser.close()