最近入手的這一批藍芽模組是屬於HC-05,設定方式指令和設定HC-06不相同,相較之下複雜的多,嘗試多次後終於成功,就把這三十多片都設定完成。 這一批的預設藍芽裝置名稱是「HC-05」,預設baudrate是「38400」 我沒有買「USB轉TTL」的轉接器,而是將藍芽模組用杜邦線連上Arduino UNO,利用Arduino IDE上傳程式到Arduino UNO板子上,打開Arduino IDE的終端機下指令設定 一、首先將程式上傳到Arduino上 程式如下: /* 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())
留言
張貼留言