我想讓我的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