Arduino UNO连接到HM-10,返回AT命令

时间:2015-10-23 16:29:24

标签: bluetooth arduino-uno hm-10

我把我的HM-10连接到我的Arduino UNO,我正在尝试AT命令。无论我发送什么命令,我都会继续 。我是Arduino的新手,并使用http://www.blueluminance.com/HM-10-as-iBeacon.pdf指南来设置芯片。这是我用于电路板的代码

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1); // RX, TX

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
  // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Goodnight moon!");

 // set the data rate for the SoftwareSerial port
 mySerial.begin(9600);
 mySerial.println("Hello, world?");
}

void loop() // run over and over
{
 if (mySerial.available())
     Serial.write(mySerial.read());
 if (Serial.available())
     mySerial.write(Serial.read());
}

1 个答案:

答案 0 :(得分:0)

mySerial.write(Serial.read());切换为mySerial.println(Serial.read());

Serial.write不会转换数据,而Serial.print会转换为字符。如果这样做,可能会将Serial.write切换为相同的。