#include "BluetoothSerial.h" //This library has the Bluetooth Capabilities for the program #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) //This three lines make sure that the bluetooth is enabled #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it // and ready to connect, if not, it starts again #endif // until it is propperly enabled. BluetoothSerial SerialBT; //This creates and instance called SerialBT. void setup() { Serial.begin(115200); //We begin the Serial communication at a baud rate of 115200 SerialBT.begin("Bbto32"); //This defines the device's name as "Bbto32" Serial.println("The device started, now you can pair it with bluetooth!"); //This promt will be printed as soon as the BT is //initialized. } void loop() { //This part of the code will send and recieve data, and print it on the serial monitor. if (Serial.available()) { //Here we are checking if there are any bytes of information recieved in the SerialBT.write(Serial.read()); //serial port, if there are any, it sends it via Bluetooth to the other device. } //SerialBT.write sends the data via Bluetooth. if (SerialBT.available()) { //This part checks if there are any bytes available to read on the serial Serial.write(SerialBT.read()); //port, if there are any, they will be printed on the serial monitor. } delay(20); }