-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hc06Setup.ino
41 lines (35 loc) · 1.11 KB
/
Hc06Setup.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Basic bluetooth test sketch. HC-06_01_9600
// HC-06 ZS-040
//
//
// Uses hardware serial to talk to the host computer and software serial for communication with the bluetooth module
//
// Pins
// BT VCC to Arduino 5V out.
// BT GND to GND
// BT RX to Arduino pin 3 (through a voltage divider)
// BT TX to Arduino pin 2 (no need voltage divider)
//
// When a command is entered in the serial monitor on the computer
// the Arduino will relay it to the bluetooth module and display the result.
//
// These HC-06 modules require capital letters and no line ending
//
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX
void setup()
{
Serial.begin(9600);
Serial.println("Arduino with HC-06 is ready");
// HC-06 default baud rate is 9600
BTSerial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
// Keep reading from HC-06 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-06
if (Serial.available())
BTSerial.write(Serial.read());