2 Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus
3 For more information visit my blog: http://blog.tkjelectronics.dk/ or
4 send me an e-mail: kristianl@tkjelectronics.com
10 // Satisfy the IDE, which needs to see the include statment in the ino too.
12 #include <spi4teensy3.h>
17 //USBHub Hub1(&Usb); // Some dongles have a hub inside
19 BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
20 /* You can create the instance of the class in two ways */
21 SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000"
22 //SPP SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so
24 bool firstMessage = true;
28 #if !defined(__MIPSEL__)
29 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
31 if (Usb.Init() == -1) {
32 Serial.print(F("\r\nOSC did not start"));
35 Serial.print(F("\r\nSPP Bluetooth Library Started"));
38 Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well
40 if (SerialBT.connected) {
43 SerialBT.println(F("Hello from Arduino")); // Send welcome message
45 if (Serial.available())
46 SerialBT.write(Serial.read());
47 if (SerialBT.available())
48 Serial.write(SerialBT.read());