HC-06 VCC → Arduino 5V
HC-06 GND → Arduino GND
HC-06 TXD → Arduino pin 10 (RXD)
HC-06 RXD → Arduino pin 11 (TXD)
----------------------------arduino code-------------------------------------
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(9600); // HC-06 current bound rate (default 9600)
}
void loop()
{
// Keep reading from HC-06 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-06
if (Serial.available())
BTSerial.write(Serial.read());
}
------------------------HC-06 AT command----------------------------------------
HC-06 只有簡單的 AT command,按完「AT」馬上回應「OK」。其它的指令要用大寫。
- AT:測試,回應「OK」
- AT+VERSION:回應靭體的版本。
- AT+NAMExyz:將裝置名稱改為「xyz」。n
- AT+PIN1234:將連線密碼換為「1234」。
- AT+BAUD4:將 baud rate 換為 9600。
- AT+BAUD5:將 baud rate 換為 19200
- AT+BAUD6:將 baud rate 換為 38400
- AT+BAUD7:將 baud rate 換為 57600