2014-05-13 47 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

相关问题