2 Example sketch for the HID 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
9 #include "KeyboardParser.h"
10 #include "MouseParser.h"
12 // Satisfy the IDE, which needs to see the include statment in the ino too.
14 #include <spi4teensy3.h>
19 //USBHub Hub1(&Usb); // Some dongles have a hub inside
20 BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
22 /* You can create the instance of the class in two ways */
23 // This will start an inquiry and then pair with your device - you only have to do this once
24 // If you are using a Bluetooth keyboard, then you should type in the password on the keypad and then press enter
25 BTHID bthid(&Btd, PAIR, "0000");
27 // After that you can simply create the instance like so and then press any button on the device
30 KbdRptParser keyboardPrs;
31 MouseRptParser mousePrs;
35 #if !defined(__MIPSEL__)
36 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
38 if (Usb.Init() == -1) {
39 Serial.print(F("\r\nOSC did not start"));
43 bthid.SetReportParser(KEYBOARD_PARSER_ID, (HIDReportParser*)&keyboardPrs);
44 bthid.SetReportParser(MOUSE_PARSER_ID, (HIDReportParser*)&mousePrs);
46 // If "Boot Protocol Mode" does not work, then try "Report Protocol Mode"
47 // If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report
48 bthid.setProtocolMode(HID_BOOT_PROTOCOL); // Boot Protocol Mode
49 //bthid.setProtocolMode(HID_RPT_PROTOCOL); // Report Protocol Mode
51 Serial.print(F("\r\nHID Bluetooth Library Started"));