microbit | A Rust crate for BBC micro : bit development
kandi X-RAY | microbit Summary
kandi X-RAY | microbit Summary
microbit contains everything required to get started using Rust to create firmwares for the fabulous BBC micro:bit microcontroller board. This little board has everything and a kitchen sink built-in, even a capable debugging interface.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of microbit
microbit Key Features
microbit Examples and Code Snippets
Community Discussions
Trending Discussions on microbit
QUESTION
I was trying to make some kind of Boxel Rebound game for the micro:bit, and I was coding at the online web editor. It all worked fine, until I tried to implement the jumping. When I start the program, it works fine, and I get my debugging messages in the REPL:
...ANSWER
Answered 2021-Jun-05 at 09:01Your Player
Object has both an attribute and a method called jump
(in your __init__
you have self.jump = 0
). This is what your player.jump()
is using (while you expect it to use the method) and you obviously cannot call an int as a method.
Change the name of one of the two (attribute or method) and it should work.
QUESTION
Using this basic example code from microbit, blinking heart, I tried to change the delay of blinking with the pause argument. However, the minimum actual blinking frequency is around 500ms, no matter what value i put.
Do you know why, and how I can achieve much faster blinking with led patterns (like show_icon
or show_leds
function).
ANSWER
Answered 2021-May-08 at 16:41You have tagged this as micropython
but I don't believe that is what you are using. I think you are running with the Python in the MakeCode editor.
Looking at the help page for for the MakeCode show_icon, it says it is called with:
QUESTION
I am currently teaching a remote middle school summer camp next year that involves microcontroller programming. I’ve chosen to avoid Arduino microcontrollers for the camp and use a MicroPython compatible microcontroller instead. One microcontroller that I am interested in using is the Lolin V 1.1.0 with an ESP-Wroom-32 chip since it is cheap and reliable.
One downside that I’ve noticed with this MCU is that a VCP driver needs to be installed in order to establish a USB to UART connection (It contains a CP210x chip). I’m not too sure how many Operating systems have a VCP driver installed by default. However, I tested to see if the microcontroller was able to be registered on three of my different laptops. On two MacBook airs, my computer was successfully able to locate the MCU without a virtual driver installed. Similarly, I used a Windows computer and a connection was able to be established after 10 minutes (Not sure why it took this long). Finally, I tried it on my friend’s European MacBook and his computer wasn’t able to locate the microcontroller until I installed the driver.
I’m expecting that the camp would be ~300 students and I don’t want anyone to not be able to connect with their Microcontrollers and don’t want to include the installation of the driver since it can be tedious.
Does anyone know how big companies that teach Microcontroller programming to beginners such as MicroBit, Raspberry Pi, or Arduino deal with this problem? How do they ensure that the microcontrollers are read by the computer without having to have students to go through the tedious process of installing a driver?
What percentage of Operating systems have a CP210x VCP driver already installed?
Are there any microcontrollers that don’t require a USB to UART driver installation altogether?
Thanks! Ryan
...ANSWER
Answered 2021-Mar-22 at 07:00The only one I am aware of that is pre-installed in windows is microchip PIC (eg PIC16F1454) but a PIC is not the best device for teaching. You have to run an application on the device to use USB VID:PID 04D8:000A.
I don't have a machine to test it but maybe a microchip MCP2200 (04D8:00DF) will be the same.
QUESTION
I'm writing a module for an I2C temperature sensor (TMP117) with cross-compatability being a priority.
The MicroPython implementation is different on BBC Micro:bit and Raspberry Pi Pico - an important difference is how the I2C driver is implemented:
- Pico uses the machine class to drive i2c:
i2c.writeto
- Micro:bit has already defined
i2c.write
(bundled withfrom microbit import *
) docs
This simple difference in naming is really all that affects compatability!
So far I have shoehorned a working solution so my module tmp117.py
is usable on both platforms.
In tmp117.py
, when the sensor class is initialised it checks the sysname
and declares function pointers self.i2cWrite
and self.i2cRead
that are assigned the hardware-appropriate definition.
However, I'm quite new to Python and imagine I may have committed many atrocities in doing so by eg. mishandling namespaces or chewing up memory with inappropriate imports. Can anybody comment if this method is appropriate? In terms of scalability, needless imports, namespaces etc.
main.py
...ANSWER
Answered 2021-Mar-13 at 23:35my choice of doing the same thing would be define _PLATFORM
variable, set it accordingly and use it later:
QUESTION
I am trying to set up a very simple example using the ada I2C library with the MCP23017 IO expander on the micro:bit (V1.5) but I can't figure it out. For now, all I want to do is turn on an LED that is connected to a GPIOA pin. I have it working in python with the following:
...ANSWER
Answered 2021-Feb-20 at 19:49I had an MCP23017 in 2012; can’t find it, so hard to help other than by suggesting lines of approach.
Have you tied the three settable address lines in the datasheet Fig 3.6 (pins 15, 16, 17 in the diagram on the first page) to ground?
You don’t check that the returned Status
from the Master_Transmit
calls is HAL.I2C.Ok
.
Looking at line 135 of nrf-twi.adb
QUESTION
I followed the adacore tutorial on displaying scrolling text (https://blog.adacore.com/ada-for-microbit-part-1-getting-started) but can't get it working on my microbit.
Maybe my microbit is a more recent version that is not yet supported? The reason I suspect this is that my board id (9904) was not supported the first time I tried to flash to the board. I used the fix described here: Unable to get the Ada scrolling text demo working on the microbit on GNAT 2019 community edition and added the following line in board_ids.py:
...ANSWER
Answered 2021-Jan-23 at 14:12libusb is missing or not found on your computer. It is used to communicate with the Microbit board to upload/debug.
QUESTION
I would like to ask some help from you. I'm trying to connect a distance sensor to my microbit but when I use the command "time_pulse_us" it always gives -2 or -1. I read the documentation, I understand the meaning of those numbers but I think there's a problem with the command or probably I'm using it the wrong way.
In that regard, I wrote a simple snippet to test the command. Could you tell me what's wrong with it?
...ANSWER
Answered 2021-Jan-12 at 13:00time_pulse_us()
runs sequentially, not in the background, so at the call it will wait 1 second for the pin to reach 1, which it will not do, hence time
will be set to -2, before the program goes on to the next command write_digital(1)
.
QUESTION
My son and I are trying to implement one of the fun-science.org microbit tutorials - building a "tug of war" game. Essentially, 10 presses on button A moves the sprite closer to that button and the same applies on button B. When you hit the edge of the screen, music plays and a message is scrolled on the screen before the game restarts.
We've got it fully working, but once the game has been won, it doesn't seem to reset properly. It works fine on the simulator, but not on the physical device (a microbit 2).
Once the game is won, the behaviour is erratic. It usually puts the sprite back in the middle, sometimes not, but frequently, one button doesn't work in the next game. Occasionally both stop working. In every situation, a restart fixes things.
Is there something wrong with the code? I've wondered whether the music / message is corrupting something and I need to put a wait in for it to complete. I've re-downloaded the hex file and re-flashed the microbit several times, so I think I've eliminated a corrupt code file.
Javascript version of code shown below, but it was actually built in blockly using the Microsoft MakeCode tool.
...ANSWER
Answered 2021-Jan-02 at 16:12I found it was more reliable if I did game.pause() and game.resume() while scrolling the text and playing the music at the end of the game:
QUESTION
this is how we get the device name using blocks But I need to find the way to code in micropython to find the same.
from microbit import * while True: basic.show_string(control.device_name())
This throws an error!
...ANSWER
Answered 2020-Oct-23 at 21:44micropython for the micro:bit is different from the code used in the MakeCode editor.
They are both based on Hardware Abstraction Layer defined at the following location: https://lancaster-university.github.io/microbit-docs/concepts/
The documentation for micropython is available at: https://microbit-micropython.readthedocs.io/en/v1.0.1/microbit_micropython_api.html
There is not a unique name in the same way that there is in blocks.
QUESTION
I am playing around with bbc:microbit using bluetooth web api to access the microbit service data (button event, led, magnetometer, ...).
It looks like the light sensor information are not accessible from the javascript API. From the microbit documentation, light sensing are accessible from the led service, but it looks like the lib is missing them.
...ANSWER
Answered 2020-Sep-12 at 21:07The micro:bit Bluetooth profile is defined at:
https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html
It does not expose the light sensor information by default over Bluetooth. My initial thought for a quick workaround is that you could send the value over the Bluetooth UART service. I used the editor at: https://makecode.microbit.org/#editor to create a hex file for the micro:bit that seemed to work:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install microbit
A BBC micro:bit board
A computer (macOS and Linux work perfectly, Windows tested as well)
A bit of open source software
The examples make use of some of the fantastic tooling from the knurling project. In order to run the examples you need to install probe-run and flip-link.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page