BLE HID Mouse¶
Overview¶
The BLE HID Mouse sample demonstrates how to use the GATT Human Interface Device (HID) Service to implement a mouse input device that you can connect to your computer.
This sample code enumerates the nRF52840 Connect Kit into a BLE HID mouse that has a left button connected to the USER button.
Tip
adafruit_ble
and adafruit_hid
are pre-built into CircuitPython as frozen modules, so that they can be imported in the code directly.
Requirements¶
Before you start, check that you have the required hardware and software:
- nRF52840 Connect Kit running the CircuitPython firmware
- 1x USB-C Cable
- Mu Editor
- A computer running macOS, Linux, or Windows 7 or newer, with Bluetooth LE supported
Running the code¶
To run the code, complete the following steps:
- Connect nRF52840 Connect Kit to your computer using the USB-C Cable.
- Start Mu Editor, click Load to open
code.py
in the CIRCUITPY drive. -
Copy and paste the following code into
code.py
and click Save: -
Your code will run as soon as the file is done saving. A Bluetooth mouse with the name
CIRCUITPY MOUSE
can be discovered by your computer. Connect to the mouse. -
Press USER button on the board, and observe that a left mouse click is activated.