2014-05-13 53 views
1

這是我的問題。我有一臺Arduino Mega 2560與我的電腦上的USB連接(Windows 7)。在Arduino上,我連接了藍牙設備HC-06。我將以下程序上傳到我的arduino:發送數據從膩子藍牙HC-6連接在Arduino

#include <SoftwareSerial.h>// import the serial library 

SoftwareSerial Genotronex(14, 15); // RX, TX 
int BluetoothData; // the data given from Computer 

void setup() { 
// put your setup code here, to run once: 
Genotronex.begin(9600); 

} 

void loop() { 

BluetoothData=Genotronex.read(); //read incoming data 
Genotronex.println(BluetoothData); //print data received from bluetooth 



    delay(100);// prepare for next data ... 
} 

我成功地將我的arduino連接到藍牙。接下來,我使用膩子並連接到藍牙,但問題是它打印「-1」,這意味着到藍牙的傳入數據是「-1」,但我不會從任何其他程序發送任何數據。我也嘗試從膩子中發送其他數據,但沒有奏效。感謝和抱歉我的英語。

回答

0

嘗試類似的東西,以確保你得到了一些數據之前將其發送到計算機

void loop() 
{ 
    if (Genotronex.available()) 
    { 
     BluetoothData=Genotronex.read(); 
     Genotronex.write(BluetoothData); 
    } 
    delay(100); 
} 

,你必須檢查HC-06的配置? HereHere

+0

後在搜索一個網站,說我的TXD和RXD,以便接收數據連接上的Arduino的的10個11引腳的藍牙我無心的日子。我不知道爲什麼它不能工作。 – user3354185

相關問題