1
我正在從項目中獲得data
from Arduino serially
並將它們訪問到Python
。要從arduino訪問數據,我使用的是pyserial
。之後,我必須在Python GUI
上顯示該數據。 我該怎麼做?如何顯示Arduino串行數據到python gui?
我在Arduino Serial Monitor
得到這個數據....
2.00
2.64
3.28
3.92
4.56
5.20
5.84
6.48
7.12
7.76
8.40
9.04
9.68
10.00
9.69
16.59
23.50
30.40
37.31
44.21
51.11
58.02
64.92
71.82
78.73
82.18
而且使用pyserial
我得到這個數據作爲python output
...
[2.0]
[2.0, 2.64]
[2.0, 2.64, 3.28]
[2.0, 2.64, 3.28, 3.92]
[2.0, 2.64, 3.28, 3.92, 4.56]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92, 71.82]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92, 71.82, 78.73]
[2.0, 2.64, 3.28, 3.92, 4.56, 5.2, 5.84, 6.48, 7.12, 7.76, 8.4, 9.04, 9.68, 10.0, 9.69, 16.59, 23.5, 30.4, 37.31, 44.21, 51.11, 58.02, 64.92, 71.82, 78.73, 82.18]
在python
我已經使用這個代碼得到Serial data
....
import serial
arduino = serial.Serial('COM5', 9600, timeout = .1)
arduino_data = [] # declare a list
while True:
data = arduino.readline()
if data:
arduino_data.append(float(data)) # Append a data to your declared list
print arduino_data
是什麼的時候似乎'pyserial'和'arduino'在你的問題中,相關性是所有關於*如何顯示在Python GUI數據*?你可以更具體一點*你想如何顯示你的數據*?你能提供一個*數據例子*嗎?注意:**編輯**你的問題添加相關信息,不要使用評論。 –
偉大**編輯**,upvoted。現在,*你想達到的最終結果是什麼*?你只是想繪製一個活動圖,或者你想要一個完整的應用程序嗎? –
@ PatrickTrentin..Thanks爲upvoting ...不住圖形,但可以說,它周圍的整個應用程序,即。只需創建一個窗口,可以顯示我在shell.which我已經顯示在myquestion爲'pyserial output'蟒蛇得到串行數據。 – karanrp