我想让我的ardunio通过蓝牙与我的覆盆子pi进行通信。到目前为止,我已经让他们使用Minicomm进行通信,但我还没有成功使用pyserial。我已经尝试过无数次的事情,但是我无法完成它的工作; 有几件事情我肯定知道(从minicomm和其他的东西):蓝莓与覆盆子pi
- 有一个连接
- 串口它的/ dev/rfcomm0
- 上的Arduino的代码工作
- 该BPS是9600
这里是我有我的PI
import serial
import time
port="/dev/rfcomm0"
print('hello world')
bluetooth= serial.Serial(port,9600)
print ('hello world 2')
bluetooth.flushInput()
print ('hello world 3')
for i in range(100):
print("we are in the for loop",i)
inputs=bluetooth.readline()
print("we are in the inputs for loop",i)
inputasinteger= int(inputs)
if inputs:
print('we have inputs')
fileb= open("blue.txt",'wU')
fileb.write(inputasInteger*10)
time.sleep(.1)
print('sleeping')
fileb.close()
print('file has been closse')
exit()
01码
你可以假设缩进是正确的......我不确定如何在这里修复它们 但是我的代码运行到line inputs = bluetooth.readline();那么它只是挂起 有没有人有这方面的经验?任何解决方案知道我可以使用的任何其他模块?
我改正了缩进,我认为,用空格替换标签,请仔细检查我做对了,如果你有时间。 – dsolimano