【问题标题】:Send data from putty to bluetooth HC-6 connected on Arduino将数据从腻子发送到连接在 Arduino 上的蓝牙 HC-6
【发布时间】:2014-07-01 13:34:21
【问题描述】:

这是我的问题。我在我的电脑(Windows 7)上有一个通过 USB 连接的 Arduino Mega 2560。在 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 与蓝牙连接。接下来我使用腻子并连接到蓝牙,但问题是它打印“-1”意味着蓝牙的传入数据是“-1”,尽管我没有从任何其他程序发送任何数据。我也尝试从腻子发送其他数据,但它没有用。感谢并为我的英语感到抱歉。

【问题讨论】:

    标签: bluetooth arduino putty


    【解决方案1】:

    尝试类似的方法以确保您在将数据发送到计算机之前收到了一些数据

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

    你检查过 HC-06 的配置了吗? HereHere

    【讨论】:

    • 经过几天的搜索,我偶然发现了一个网站,上面说我必须在 arduino 的 10 和 11 引脚上连接蓝牙的 TXD 和 RXD 才能接收数据。我不知道为什么它不能正常工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-09
    • 2015-07-18
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多