Created
April 24, 2014 20:06
-
-
Save mathieulesniak/11267735 to your computer and use it in GitHub Desktop.
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
#include <SoftwareSerial.h> | |
// Pins | |
#define BT_PIN_TX 7 | |
#define BT_PIN_RX 6 | |
#define BT_PIN_KEY 5 | |
SoftwareSerial BTSerial(BT_PIN_RX, BT_PIN_TX); | |
void setup() | |
{ | |
pinMode(BT_PIN_KEY, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode | |
digitalWrite(BT_PIN_KEY, 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()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment