Can the Microbit access USBMouse and USBKeyboard code

15 Oct 2019

Can the Microbit access USBMouse and USBKeyboard code

Hi.

I posted this as a question but have not got a reply so a thought I would raise it on the forum.

I have a small project that would use an accelerometer to move the mouse around the screen. I also have 3 Microbit boards (the only boards I currently have with accelerometer) and I am a fan so I tried to implement the project on this.

I am using the online mbed compiler.

I had significant trouble getting sample accelerometer code to compile. I finally got it to work using the code from:

https://github.com/lancaster-university/microbit-samples/tree/master/source/examples/accelerometer

This is the ONLY example that compiles cleanly an runs.

So now my issue is the USB Mouse (Mouse/Keyboard HID emulation). When I go to the 'mbed' imports I cannot get it to compile. I select fix and it imports some stuff then I get different issues. I googled the results, did an update all as recommended but this dis not resolve the issue.

Can you please tell me if what I am trying is possible with the existing mbed/microbit libraries? I need both accelerometer and USBMouse/Keyboard.

I do not think I would be able to code my own USBMouse HID complient interface, I spent some time looking at the mbed code and read the HID spec and while I understand the basics it is way too complex for a beginner like me.

Please could somone assist

Regards

Stuart

18 Oct 2019

Hi Stuart,

Mbed OS has USBMOUSE API. https://os.mbed.com/docs/mbed-os/v5.14/apis/usbmouse.html

microbit is with NRF51 on it, so checking if it supports usbdevice in targets.json https://github.com/ARMmbed/mbed-os/blob/0efea30377eadac34944c6c2de2dbcb9b237b5f5/targets/targets.json#L5047

It doesn't support USB device function, so unfortunately, you might need do porting effort on it, if you would like mount microbit as a usb device...

Regards, Desmond

You need to log in to post a reply