【发布时间】:2017-06-20 10:33:44
【问题描述】:
pySerial write() won't take my string
在那篇文章中,编码人员解释了如何使用
ser.write()
方法。
我还在想如何使用
readline()
python3.x 中的方法,因为我想接收一个浮点数,并在我的 python 3.x 代码中进行比较。我知道如何在 python 2.7 中使用 readline() 。但我无法让它在 3.x 中工作。
import serial
import time
ser=serial.Serial('/dev/ttyACM0', 9600)
while 1:
ans = ser.readline()
print(ans)
if ans > 25.50:
print('its getting hot in here')
else:
print('Everything is fine')
提前致谢
【问题讨论】:
标签: python arduino sensors pyserial