因為在上一篇的教學 (透過藍牙無線更新Arduino UNO 軟體) 中有用 USB 轉 serial 模組,有人就在問可不可以不用此模組? 答案當然可以。請參考下方步驟:
事前準備:
1. 可先參考 (透過藍牙無線更新Arduino UNO 軟體)
2. 確定HC 05 中的 Baud rate 已改成 115200
3. 準備下方模組
MAC NB
Arduino UNO
HC 05 藍牙模組
硬體接法:
1. Pin 7 與Reset pin 連接
2. HC 05 上的 TX RX 要接上Arduino 上的 RX TX (請記得要交換連接)
3. 將HC 05 上的 VCC 接上 Arduino 5v pin
4. 將HC 05 上的 GND 接上 Arduino GND pin
先將此程式碼上傳至你的UNO 中
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define RESET_PIN 7 | |
#define RESET_CMD_SIZE 4 | |
char myChar; | |
int i=0; | |
static char RECEIVE_RESET_CMD[RESET_CMD_SIZE] = {0x00, 0x00, 0x00, 0x00}; | |
void reset() { | |
Serial.println("Reset"); | |
digitalWrite(RESET_PIN, LOW); | |
delay(100); | |
digitalWrite(RESET_PIN, HIGH); | |
} | |
void setup() { | |
digitalWrite(RESET_PIN, HIGH); | |
Serial.begin(115200); | |
Serial.println("Start"); | |
pinMode(RESET_PIN, OUTPUT); | |
} | |
void loop() { | |
while (Serial.available()) { | |
myChar = Serial.read(); | |
if (myChar == 0x30 || myChar == 0x20) { | |
RECEIVE_RESET_CMD[i]=myChar; | |
if (RECEIVE_RESET_CMD[0] == 0x30 && | |
RECEIVE_RESET_CMD[1] == 0x20 && | |
RECEIVE_RESET_CMD[2] == 0x30 && | |
RECEIVE_RESET_CMD[3] == 0x20 ) { | |
reset(); | |
} | |
i++; | |
} | |
else { i=0;} | |
} | |
} |
MAC 上設定:
將藍牙設定開啟
搜尋完成後,和你的藍牙模組配對

輸入PIN 碼 (請注意你的PIN是否有被更改過)

當輸入正確PIN碼後,藍牙模組上的LED 閃爍頻率會變慢,可得知已配對好並連線成功了。
有時在沒有通訊時,會斷開連線,藍牙模組上的LED 閃爍頻率就又變的比較快了。
從MAC藍牙無線更新Arduino UNO 軟體:
配對完成後,你可以設定藍牙成為你要上傳的 port
不過要注意的是,本文章中的程式碼會在燒code前去拉reset,若要一直能有無線燒機的能力的話,務必要在新的程式碼中加上文章中的程式碼。
延伸學習:
1. 是否可以讓 PC 上的藍牙也做到同樣的無線更新呢?
2. 是否可以不要浪費 Pin 7 去拉Reset呢?
關鍵字:
Arduino,無線刷機,藍牙,HC 05