HC-05 修改設定

/*  HC-05 needs connect "EN" to Pin 6
 *  AT              return OK
 * AT+VERSION      get version
 * AT+NAME=xxx     xxx is new name.
 *  HC-05 RX connects to Arduino Pin 11, HC-05 的RX 接到Arduino Pin 11
 *  HC-05 TX connects to Arduino Pin 11, HC-05 的TX 接到Arduino Pin 10
 */
#include <SoftwareSerial.h>   
SoftwareSerial BT(10, 11); // RX 10 , TX 11 
char val;   
void setup() { 
  Serial.begin(9600);   // 與電腦序列埠連線
  Serial.println("BT is execution!");
  // HC-05 is 38400 BPS and "Both NL & CR", 如果是HC-05,請改成38400
  // HC-06 is 9600 BPS and "No line ending",  如果是HC-06,請改成9600
  BT.begin(38400);  
}
void loop() {
  if (Serial.available()) {    
    val = Serial.read();
    BT.print(val);
  }
  if (BT.available()) {    
    val = BT.read();
    Serial.print(val);
  }
}

arduino
CH00 前言CH01 簡介篇CH02 Arduino 硬體介紹CH03 Arduino 開發環境介紹CH04 我的第一個ArduinoCH05 Digital 數位輸入與輸出CH06 專案CH07 感應器CH16 Android 和 iOS 手機與 Arduino 連接CH99 問題集