首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将数据从putty发送到Arduino上连接的蓝牙HC-6

将数据从putty发送到Arduino上连接的蓝牙HC-6
EN

Stack Overflow用户
提问于 2014-05-14 02:15:27
回答 1查看 2.2K关注 0票数 1

这就是我的问题。我有一个Arduino Mega2560与USB连接在我的pc (Windows7).On的arduino我连接了一个蓝牙设备HC-06。我将以下程序上传到我的arduino:

代码语言:javascript
复制
 #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发送其他数据,但不起作用。感谢并为我的英语道歉。

EN

回答 1

Stack Overflow用户

发布于 2014-05-14 23:39:25

尝试类似的操作,以确保在将数据发送到计算机之前已接收到一些数据

代码语言:javascript
复制
void loop() 
{
    if (Genotronex.available())
    {
        BluetoothData=Genotronex.read();
        Genotronex.write(BluetoothData);
    }
    delay(100);
}

你有没有检查HC-06的配置?HereHere

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23638677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档