这就是我的问题。我有一个Arduino Mega2560与USB连接在我的pc (Windows7).On的arduino我连接了一个蓝牙设备HC-06。我将以下程序上传到我的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连接到了蓝牙。接下来,我使用putty并连接到蓝牙,但问题是它打印"-1“,这意味着进入蓝牙的数据是"-1”,尽管我没有从任何其他程序发送任何数据。我还试图从putty发送其他数据,但不起作用。感谢并为我的英语道歉。
发布于 2014-05-14 23:39:25
尝试类似的操作,以确保在将数据发送到计算机之前已接收到一些数据
void loop()
{
if (Genotronex.available())
{
BluetoothData=Genotronex.read();
Genotronex.write(BluetoothData);
}
delay(100);
}你有没有检查HC-06的配置?Here和Here
https://stackoverflow.com/questions/23638677
复制相似问题