microbit | Using micro : bit with the LEGO MINDSTORMS EV3
kandi X-RAY | microbit Summary
kandi X-RAY | microbit Summary
Using micro:bit with the LEGO MINDSTORMS EV3. The BBC micro:bit is a small ARM-based embedded system designed for Education. It has a few sensors, LEDs, buttons and GPIO pins and can be used through USB or Bluetooh Low Energy. This is a quick demonstration of how we can use a LEGO MINDSTORMS EV3 to communicate with a micro:bit through BLE. Will just how to present something in the the LED Matrix and read the two buttons but is very easy to use all the onboard devices.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handle data received .
microbit Key Features
microbit Examples and Code Snippets
Community Discussions
Trending Discussions on microbit
QUESTION
I’m new to both micro:bit and MicroPython (or Python in general) - but I want to have it all running in VSCode. I grabbed this extension which was really smooth working with.
My problem now is that I want to leverage external modules, for things like the NeoPixels and also the bit:bot stuff, but I don’t know how to actually get that working. The NeoPixel tutorial is straight forward, but there is no mention on how to add the module.
I tried adding them with pip - but that won’t make them end up on the device. I’ve also tried this extension - hoping it would do some more magic in getting it onto the device.
Is this doable? Or would I have to revert do the online editors?
...ANSWER
Answered 2022-Jan-11 at 07:43The micro:bit is a very constrained environment and will not run Python only MicroPYthon. MicroPython was designed to work under the constrained conditions of a microcontroller. As a result MicroPython does not come with the full Python standard library and only includes a small subset of the Python standard library.
For MicroPython to run on the micro:bit there needs to be the MicroPython hex file and any Python code that you have written, with main.py
being the entry point.
The VS Code Extensions you linked to use uFlash to copy from your machine to the micro:bit the hex file and any Python files you have written.
To use the neopixel module it should be as straight forward as import neopixel
as it is part of the standard BBC micro:bit MicroPython.
For BitBot, it only uses the standard micro:bit MicroPython library so I'm not sure what you are looking to import.
You can create a module by putting the code in .py
file and referencing it in your main.py
file. You do this by using an import statement that calls the file or specific parts of it.
MicroPython does have the concept of upip but I am not aware of that being available on micro:bit.
QUESTION
I am making a small webpage which controls a Microbit and shows some sensor data.
I am trying to implement asynchronous read and writes to the microbit through my flask backend based on the things I click on the front end.
But when I use flask to run a function I have it gives an error which says
...ANSWER
Answered 2021-Aug-04 at 14:00The error indicates that there in no event loop in not MainThread, for async programs in Python we usually have only one asyncio
loop in MainThread, we do not want more asyncio
loops, since they'll be fighting each other for time and the whole app will be slower and more prone to errors.
If I were you I would use aiohttp
or any other async http framework instead of Flask, otherwise use any other not async library for serial port
.
But how you can get another loop in not MainThread if you want it? Please find example:
QUESTION
I would like to write tests for the micropython code I am writing for the micro:bit. The examples here use doctest. I am open to work arounds for any testing system.
Working python example called testing_python.py:
...ANSWER
Answered 2021-Jul-19 at 20:31unittest.mock
is a library for testing in Python. It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used.
This can be used to write and test embedded software like micropython without the hardware.
You can go as sophisticated as you want, but a simple way to not get an error on importing the microbit module is to mock the microbit
module. e.g. Have the following files:
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)
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install microbit
You can use microbit like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
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