Commit 1e2a1faf957cb27cd47828d59ce18462eaf16536
1 parent
c0932e0b
Exists in
master
Copied in serial forwarder code, which is very useful for configuring the HC-05 …
…bluetooth module. From techbitar.com, public domain.
Showing
1 changed file
with
33 additions
and
0 deletions
Show diff stats
robots/little_john/telemetry/code/serial_forwarder/serial_forwarder.ino
0 → 100644
| @@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
| 1 | +/* | ||
| 2 | + | ||
| 3 | +AUTHOR: Hazim Bitar (techbitar) | ||
| 4 | +DATE: Aug 29, 2013 | ||
| 5 | +LICENSE: Public domain (use at your own risk) | ||
| 6 | +CONTACT: techbitar at gmail dot com (techbitar.com) | ||
| 7 | + | ||
| 8 | +*/ | ||
| 9 | + | ||
| 10 | +#include <SoftwareSerial.h> | ||
| 11 | + | ||
| 12 | +SoftwareSerial BTSerial(3, 2); // RX | TX | ||
| 13 | + | ||
| 14 | +void setup() | ||
| 15 | +{ | ||
| 16 | + pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode | ||
| 17 | + digitalWrite(9, HIGH); | ||
| 18 | + Serial.begin(9600); | ||
| 19 | + Serial.println("Enter AT commands:"); | ||
| 20 | + BTSerial.begin(38400); // HC-05 default speed in AT command more | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +void loop() | ||
| 24 | +{ | ||
| 25 | + | ||
| 26 | + // Keep reading from HC-05 and send to Arduino Serial Monitor | ||
| 27 | + if (BTSerial.available()) | ||
| 28 | + Serial.write(BTSerial.read()); | ||
| 29 | + | ||
| 30 | + // Keep reading from Arduino Serial Monitor and send to HC-05 | ||
| 31 | + if (Serial.available()) | ||
| 32 | + BTSerial.write(Serial.read()); | ||
| 33 | +} |