Micro:bit Human Interface Devices over BLE: Examples
HTML-код
- Опубликовано: 10 сен 2024
- This shows examples of a micro:bit V2 acting as Human Interface Devices over Bluetooth. Examples include: A keyboard for a computer (macOS and Windows), a mouse for a computer (macOS shown), a shutter release for an Android tablet, a media remote for an iPhone, and a Gamepad for an Android tablet. (Actual iOS and Android devices were used and screencast to a computer, which is what's shown in the video)
It can be added to a project by:
1. Create/Open a project
2. Click the gear icon in the upper right
3. Select "Extensions"
4. Type "BLE HID" in the "Search or enter project URL..." and hit enter.
5. Click on the microbit-pxt-blehid tile.
6. You'll be prompted to remove the "Radio" blocks. Select the "Remote extension(s) and add microbit-pxt-blehid" button.
There have been two updates since the video was made:
* The error ("Program Error: Cannot read properties ...") will no longer
* The bluetooth name of the micro:bit will not be "BBC micro:bit". It will be something like "uBit [?????]", where the ????? is a 5-letter name of your specific micro:bit.
This is amazing!!! Thank you so much for developing this extension. It'll be a game-changer in supporting low-cost assistive technology. Can't wait to try it out.
Very interesting with so many options. Like Loreto in the comments said, it'll help support accessibility needs!
Loreto has already put together a great example of an assistive device: twitter.com/loretod101/status/1495154394266017794?s=20&t=P62lu0HidYqisjP3bwbjOQ
Thanks Bill!!! Such a great inspiration!!
I'm really looking forward to seeing the cool projects others come up with!
for 'mouse' how to tweak it such that microbit needs to be tilted more to move cursor?
There are several different approaches that may have subtly different behaviors. The easiest may be to just multiply the acceleration by a fraction before it's ever used. For example, in the example at makecode.microbit.org/20442-75928-77698-24331 you may want to try replacing the `acceleration` blocks (that set `newXAcc` and `newYAcc`) with `0.7 x acceleration`
The BLE HID Extension isn't available when I search for it.
The full name is microbit-pxt-blehid. I just did a quick test and it looks like it's there --- I searched for "BLE" and it was listed first. If that still doesn't work, here's an empty project that already include the BLE HID blocks: makecode.microbit.org/S55587-75114-67388-20014
so OP, thanks.
I just want to connect a Bluetooth keyboard and the micro bit in the matrix led show me the letter that I pressed
Hi, I'm sorry, but that's not something the extension shown here is able to do. This example makes the micro:bit act as a keyboard. Having the micro:bit connect to a bluetooth keyboard is technically possible, but I'm not sure if it'd be possible with MakeCode and I haven't heard about any extension that does that.
does my pc need to have a bluetooth adapter?
It needs to support Bluetooth Low Energy. Most PCs made in the last 5-6 years (since around 2017) support it. Older PCs may need an adapter. Bluetooth support must be enabled. For example, it won't work on school computers if the school disables bluetooth.
@@bsiever The motherboard I bought doesn't support it so I'm going to have to get an adapter. Thanks for the information.
great
im on a mac with a microbit, how do i install it?
Here's an example project that includes the Bluetooth blocks: makecode.microbit.org/S35370-85499-02800-55821 . Open the link and select "Edit" to edit the program. It's best to use Chrome on a Mac because it supports "WebUSB" to program the micro:bit. Here's an overview of using WebUSB to put the program on the micro:bit: makecode.microbit.org/device/usb/webusb . Once the micro:bit has the program, it will act like a bluetooth device and can be "paired" to computers, tablets, phones, etc. as shown in the video. I hope that helps!
I'm trying to use the micro:bit as a mouse like you showed in the video on Windows 10 PC but it's not working, I've copied the code and connected it via bluetooth but nothing's happening
Hi @Xyva --- I can't be sure it'll work with all set ups, but here are some things to try: 1) Here's my exact version to try: makecode.microbit.org/_7b6a48akA8zv ; 2) Unpair and then repair the micro:bit with Windows ; 3) Maybe try it on a different computer to see if it's the computer or the micro:bit that's the problem.
Hi, thanks for making this, but I followed all the steps on a Windows 10 PC, it doesn't work, nothing happens when I press the button, I tried to re-pair the micro: bit, but nothing works, do you have any suggestions?
Can you post on the extension discussion forum and include: a) a link to the micro:bit program you're using (use the share button in MakeCode) and b) a description of your computer? The discussion forum is as: github.com/bsiever/microbit-pxt-blehid/discussions
Hi, Thank you so much for developing this extension. @time 7:05 of your video I see the begin of function called "move mouse". Could you share it?
Thank a lot.
Sure! Here it is: makecode.microbit.org/_YPWV6tfmr8TW (If you do cool things with the extension, please share!)
Very cool!! The last one for temperature collection reminds me of a website that I'm building with some college students. Would be happy to share it with you. Your input would be much appreciated.
Sure! Please share!
Thanks Bill, I appreciate you and your work on this project. Was wondering if you can point me in the right direction. I'm trying to use the BLE HID on Key Press Down as soon as PIN 0 is touched. I tried it out and it works fine but only when you release the key (i have a connected arcade button). Is there any possible way to achieve on KeyPressDown? Similar to how the HID Keyboard works with the Circuit Playground Express. Many thanks , Adam.
Hi @TheRevVBand: Thanks! The problem is due to the way touches are detected, not this extension. Here's a demo that may be closer to what you want: makecode.microbit.org/_4maRTkH081XA . It will show a small heart on the "touch down" (while holding GND and P0). It seems to take about about a second for it to be detected, but it is distinct from the release. It'll show a large heart when P0 is released. For further general questions you may want to post to the micro:bit forum at: forum.makecode.com/
@@bsiever Thanks for the prompt response! I've tried that code and it does not work the way I need to, but a step in the right direction. I'm trying to build real time BLE HID keyboards so i can hook them up to web based games. The controller needs to send a keystroke in real time. here is an example with an esp32... ruclips.net/video/BkfmBk6OeQM/видео.html - would we be able to do something like this? - An even better example... ruclips.net/video/QJr3OmvUpC4/видео.html - Thanks again. (i'll check the forum if we can't get it to work) =)
@@adamfalletta You may want to take a look at Jurjen's Micro:bit-MaKey projects: gitlab.com/jurjendevries/makey-makey-microbit . If you just need 2-3 types of key event, you may want to mix-in one of my other extensions: Button Clicks (makecode.microbit.org/pkg/bsiever/microbit-pxt-clicks). Here's an example that sends keys as soon as A or B are pressed down by using Button Clicks: makecode.microbit.org/_1iHcAX0e4T5x . I think the underlying problem is due to how capacitive touch events are detected. There may be some workaround, but I won't be able to look into for a few weeks .
@@bsiever That plugin is a great way for buttons to act like keypresses. The ultimate plugin would be for onPin touch Down - this way I could hook up an external arcade button (or sensors) and build my full line products. I could also listen for analog values and send keystrokes as soon as a certain threshold is reached. I appreciate your honesty and will circle back in a few weeks to check your availability as these projects are extremely important not only to me, my partners, but for many. I hold you in the highest regard Bill and I'm hopeful that you can find it in your heart to include me in your schedule on some point down the line. If you come across anything until then I will be very glad to hear it. Sincerely Adam
@@adamfalletta Oh --- Are you using buttons? I thought you were using capacitive touch. If you're using buttons, you might get the behavior you want with pulse events, like this: makecode.microbit.org/_Xvec9tPzXbvR (Sends the key when P0 is connected to GND --- a button between GND and P0 should trigger it)
will it work in microbit V1?
No, I'm afraid this is micro:bit v2 only extension. It relies on some updates and the additional memory in the v2.
@bsiever is there any other way to use micro:bit V1 as a keyboard. I have tried with this extention on bbc micro:bit v1 but it does not work. BTW thank you for quick reply.
@@FactyTact You might take a look at this thread: forum.makecode.com/t/anyone-ever-used-microbit-as-a-controller/9959. There are a few things that are mentioned that are relevant: 1) It has a link to an older Keyboard extension that worked on the V1 (github.com/kshoji/pxt-bluetooth-keyboard) and 2) I don't think that extension works with current versions of MakeCode, but the post also mentions a trick to access older versions of MakeCode, which may still work with that extension. Vegz78 mentions using an older version of MakeCode. Good Luck!
music