
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
A python package to connect to the Bluetooth LE GATT services of BBC micro:bit devices. Use your micro:bit as a wireless game controller!
So you finished Python for kids? Wouldn't it be awesome to use your BBC micro:bit as a wireless game controller for your own DIY games? You can do it with this python package! Pair your micro:bit to your computer with bluetooth and use buttons A and B or the accelerometer to control your game. Like it? Give us a :star: on github!
Kasper's microbit is a python package to make a connection to a BBC micro:bit by means of the Bluetooth LE GATT services exposed by the micro:bit.
Watch the full video on youtube
Install kaspersmicrobit:
$ pip install kaspersmicrobit
Copy this hex file to the micro:bit and run your first program:
import time
from kaspersmicrobit import KaspersMicrobit
def pressed(button):
print(f"button {button} pressed")
with KaspersMicrobit.find_one_microbit() as microbit:
microbit.buttons.on_button_a(press=pressed)
time.sleep(10)
Visit https://kaspersmicrobit.readthedocs.io:
Or take a look at the examples directory.
Below you can find which combinations of operating systems and microbit versions have been known to work.
micro:bit v2.x | No pairing required | Just works pairing |
---|---|---|
Windows | :heavy_check_mark: | :heavy_check_mark: |
Linux | :heavy_check_mark: | :heavy_check_mark: |
MacOS | :heavy_check_mark: | :grey_question: |
I don't have a mac to test kaspersmicrobit on. Let me know here (#5) if it works or not! Thanks @RyanNorge for testing a micro:bit v2.x on MacOS in "No pairing required" mode
micro:bit v1.x | No pairing required | Just works pairing |
---|---|---|
Windows | :heavy_check_mark: | :x: |
Linux | :heavy_check_mark: | :heavy_check_mark: |
MacOS | :grey_question: | :grey_question: |
$ pip install --upgrade kaspersmicrobit
First try turning the micro:bit off and on again.
If you are not using the "with"-block, but calling .connect() yourself, always make sure that in any case you call .disconnect() when you don't need the connection anymore (for instance when you exit your application)
If the hex file was created with the setting "No pairing required" then the micro:bit should not be paired with the operating system
Don't use pairing with a micro:bit v1 on windows, use "No pairing required" instead.
For other versions: try to remove the micro:bit from the paired Bluetooth devices and pairing it your computer again.
See also: https://support.microbit.org/helpdesk/attachments/19075694226
This means the micro:bit is out of memory. You probably have enabled too many Bluetooth services in MakeCode. Or maybe your MakeCode program is too large. Because the micro:bit v1 has less memory than the v2, this has a higher chance to occur on v1 micro:bits. See also: the micro:bit error codes
When combining kaspersmicrobit with tkinter (the window library used in Python for kids) you could bump into the TK error "main thread is not in main loop". This is probably because you call TK code from within a callback function that you registered to be called when a button press occurs or new accelerometer data is present (or some other notification). The callback is executed on a different thread and tkinter does not like this. There are at least 2 solutions for this:
kaspersmicrobit.tkinter.do_in_tkinter(tk, your_callback)
this makes sure that your callback
will be executed on the tk thread, avoiding the errorFAQs
A python package to connect to the Bluetooth LE GATT services of BBC micro:bit devices. Use your micro:bit as a wireless game controller!
We found that kaspersmicrobit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.