測試使用HC-05模組是否正常工作,並設定相關參數。
Material:
HC-05模組 x 1
Pin:
Code:
/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.com)
*/
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
Tool:
使用Arduino內建終端機軟體 (使用 Pin RX、Pin TX)
另外可以使用常見終端機軟體
HC-05 AT Command:
HC-05 燈號提示:
連續閃爍:HC-05等待配對中
二秒閃一次:HC-05配對成功
Reference:
沒有留言:
張貼留言