Arduino Sketch for BT
serial communication via bluetooth
#include <SoftwareSerial.h> //downloaded library
SoftwareSerial BTserial(2, 3); // RX | TX // appropriate pins to transmit and then receive from
// Connect the HC-05 TX to the Arduino RX on pin 2.
// Connect the HC-05 RX to the Arduino TX on pin 3 through a voltage divider.
// for exmample we can use 47k and 68k resistors
//when sending from serial be sure both NL and CR are on and baud rate matches
// I have not used a voltage divider…until now
void setup()
{
Serial.begin(9600);
// HC-06 default serial speed is 9600
BTserial.begin(9600);
}
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());
}
}