#include <SoftwareSerial.h> // Include SoftwareSerial library
SoftwareSerial BT(10, 11); /*Define pins Rx and Tx on Arduiono, which are connected to Bluetooth.*/
void setup()
{
BT.begin(9600); //Initialize serial port which has been created.
Serial.begin(9600); //Initialize serial port.
}
void loop()
{
if (BT.available()) //If data arrives by BT, it is sent by Serial monitor.
{
Serial.write(BT.read()); //Data read from Bluetooth module
}
if (Serial.available()) //If data arrives by Serial monitor, it is sent by BT.
{
BT.write(Serial.read()); //Data read from from Serial monitor.
}
}