HC-05 AT命令蓝牙模块

时间:2018-02-12 14:53:23

标签: bluetooth arduino command at-command

我正在尝试使用Arduino微控制器在Proteus 8上模拟HC-05蓝牙模块的AT命令,输入命令后我得到的答案是我使用的代码:

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(5, 6); // RX | TX
int incomingByte = 0;   // for incoming serial data

void setup()
{
    Serial.begin(9600);
    Serial.println("Enter the command:");
    BTSerial.begin(38400);       // HC-05 default speed in AT command more
}

void loop()
{
    if (Serial.available() > 0) {
        // read the incoming byte:
        incomingByte = Serial.read();

        // say what you got:
        Serial.print("I received: ");
        Serial.println(incomingByte, DEC);
        if (BTSerial.available())    // read from HC-05 and send to Arduino Serial Monitor
            Serial.write(BTSerial.read());

        if (Serial.available())     // Keep reading from Arduino Serial Monitor and send to HC-05
            BTSerial.write(Serial.read());

    }
}

0 个答案:

没有答案