python 訪問串口

1. 安裝PySerial module:

pip install pyserial

2. ser = serial.Serial(DEVICE, BAUD)

具體的:

ser = serial.Serial("COM1",9600)

寫入串口:

ser.write("some text")

讀取串口:

while True:

print(ser.read())

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章