BBC Microbit with MicroPython

If you haven’t read my initial first impressions of the Microbit blog post, I would suggest have a glance over it first.

This blog post is still a work in progress.

A few months back, I got the opportunity to sit in a meeting with Nicholas Tollervey while at Raspberry Pi on internship. He had with him an item,  rarer at the time than gold dust, an early prototype of a BBC Microbit and he was very excited!
Around then, Damien George (lead developer of MicroPython) had just got a very rough build of MicroPython running on the Microbit.
Nicholas just had a very rough prototype with him which you simple got a REPL (Read Eval Print Loop, type command in, instantly get result) over a serial connection to the Microbit. But, it was enough to get us all very excited!

Since then, the project as a whole has come a huge way including the development of the excellent Mu editor and overall is now generally very stable with an excellent set of documentation.

So why is this exciting?

Although the other platforms built for kids to write code with for the Microbit are great, Python has the massive advantage that kids already learning it.
Python is by far the most popular programming language for schools today. The Microbit will work as a great inroad for schools wanting to teach new students a fun introduction to Python.
For those schools already teaching it Python, those students can go even further using some of the more advanced features and libraries!

Writing your Python code with Mu

Mu editor with the same shake program, written in Python using MicroPython.
Mu editor with the same shake program, written in Python using MicroPython.

One of the extremely exciting additions recently has been the launch of the Mu editor.

Mu is an extremely simple Python editor that has similar features to IDLE, but is far easier to use. It uses the QT platform, allowing single file executables for Windows, Mac and Linux to be built. They just work which is wonderful.
The editor allows you write your Python code, then simply hit the flash button to flash it onto your plugged in Microbit. That is it, no need to download a .hex file and copy it over manually, Mu takes care of it all.

A key feature though of Mu is it is 100% offline. No web access is required which is a very nice feature that I am sure many schools will appreciate. Although it doesn’t include an emulator like the other 3 web based editors, it doesn’t really need it given you can just hit flash and it is on your Microbit, simple.

On top of this, it also includes support for the REPL built in. The REPL commandline can be opened with a single click. This allows you to see any outputs in your script (done with print()) and even get user input using input().
I really love this given it lets you experiment and try stuff out, before writing your main program.

Along with writing your programs in the main editor then flashing them to the Microbit, you can also try out stuff using the REPL.
Along with writing your programs in the main editor then flashing them to the Microbit, you can also try out stuff using the REPL.

Using Mu in schools

Mu is a really cool tool, but I have been getting questions from a stack of teachers about using it in school on locked down school computers.


If you have Windows computers, you can grab Mu (a single .exe file, no installation needed) from the Github page (or a direct link to the downloads page).

If you want to be able to use the REPL (highly recommended) you will also need to download and install mbed driver.
It is well worth it, although you are able to do it without it. You just won’t have access to the REPL.

Mac / Linux

On Mac OS and Linux, you can download the single executable applications from the Github page (or a direct link to the downloads page for Mac OS and Linux).
There is no mbed driver needed for Mac OS/Linux as it is built in, it is built in so you can use the REPL straight away!

Raspberry Pi

There are specific versions of Mu for the Raspberry Pi! So if you want to use the Microbit with a Pi, you will soon be able to simply type “sudo apt-get install mu”, although unfortunately that isn’t ready just yet. The direct link to the Raspberry Pi versions can be found here.
There is no mbed driver needed for Raspberry Pi Linux, it is built in so you can use the REPL straight away!

External hardware

You can do some pretty cool things with MicroPython and the BBC Microbit by connecting other hardware to it.


Everyone loves flashy multicoloured LEDs, right? Well the Microbit can drive a stack of them. In our tests, it can drive at least 256 pixels at one time! I have been working on testing the module and also writing documentation for it.

You can check out the Neopixel module documentation here.


By attaching a simple buzzer to your Microbit, you can get it to play music. In the case below, Amy Mather also made use of Makey Makey style resistive touch to create a music keyboard!

You can check out the music module documentation here.

SPI/I2C modules

Unlike the other programming environments, MicroPython allows more advanced students or developers to interact with additional sensors/modules using the I2C/SPI interface libraries.

This opens up use possibilities for connecting additional modules to the Microbit. For example, you could connect an SPI LCD, an OC2 pressure sensor or even an SPI GSM modem to send text messages from your Microbit!
Is worth keeping in mind, although you could do all this, it isn’t as simple as importing a module. It will require a little work (and datasheet reading), but the important bit is people have the tools to do it.

Other peoples projects

Nicholas has also been making a few videos to demo some new Micropython features.

To conclude

I am extremely excited for MicroPython and Mu. Although there is going to be a simple web based MicroPython editor coming soon, I think many schools will want to use Mu instead given it can be run completely offline and includes awesome extra features like the REPL.

Although the other programming environments are excellent, and I take my hat off to their development teams as they have done a really great job. I still think MicroPython is the one everyone should be keeping an eye on. It has huge potential to be grabbed by students and allow them the true freedom to run with their ideas while learning a useful language at the same time!

13 thoughts on “BBC Microbit with MicroPython”

  1. Hi Andrew,

    I’m an IT Assistant at a college for blind students. We’re excited to start our younger ones off with the Microbit in september but have hit a bit of a wall!

    The QT framework is very inaccessible to screen readers. Most blind python developers use a notepad variant, or something like SciTe, rather than a huge IDE to keep things simple. I don’t yet have a Microbit of my own to play with but will be seeking a way around a QT or web-based development environment. I wonder if you might have any thoughts?

    Thanks for a great blog, this is a hugely exciting bit of kit!

    1. Hi Sean,

      I’m one of the people responsible for MicroPython on the BBC micro:bit and I also wrote the Mu editor.

      It’s interesting you should mention QT as a framework that’s inaccessible to screen readers. When I reached out to the blind/visually impaired community within the Python community, they said exactly the opposite.

      If you would like to help, contribute or test our work we’d love to hear your feedback and receive contributions. One problem we have is that all the developers involved with Mu at this moment in time are sighted, so it’s hard for us to know if our work is suitable. Being able to try things out and get feedback from blind/visually impaired users is hugely important…

      Feel free to contact me at any time via my details here:

      1. Nicholas,

        Cross-platform UI frameworks are invariably tricky for accessibility. QT has potential, probably the most potential of anything other than wx at the moment, but it needs a lot of pre-work doing on the user’s end. It’s unlikely that a computing teacher could give a blind student a copy of Mu and a Microbit and expect success unless the system had already been prepared. I need to investigate in more detail whatever dependencies are needed for particular screen readers over the coming months of course.

        I’ll drop you an email and we’ll see where we can get!


  2. Hi Andrew

    This is a cool resource to get started with! I do Outreach work for my University and also supporting teachers in getting them prepared for using this in their schools.

    One thing I came across when working on the Microbit is the ability (or lack thereof) to read and write text files. Whenever I try to author a text file using some MicroPython code, it doesn’t appear to create a text file.

    I’ve scoured the internet for potential solutions to the problem but I cannot appear to find one. Have the MicroPython API’s involving File IO been testing on a Microbit yet?

    Looking forward to hearing back from you


  3. Having just obtained a PyBoard with MicroPython and then got a BBC microbit on order , it’s nice to see a language that can be used almost instantaneously.

    Coming from a background where make files, don’t make, compilers don’t compile and linkers don’t link it’s refreshing to see something that just works quickly, either with the REPL or with the the on board flash or sdcard of the PyBoard

    With a single line you can light a led, send an i2c command or a serial command, this must make using hardware much more accessible for anyone nowadays.

    It’s seems in the hobbyist market where as people use to use individual components to built projects, now you can quickly string modules together and get all kinds of things working with minimum effort, especially if the objective is to see the end result rather than have to labour over the nitty gritty .

  4. Wonder if anyone can help. I have the code for the pong game using the neopixel, but cant get it to work. I have a 16 LED NeoPixel so have changed that accordingly on the code. Its giving me an error on line 8. (the set colour (position)) line.

    If anyone has any suggestions it would be much appreciated. (And if you see any other errors too!)

    Thanks in advance.

    from microbit import *
    import music
    import neopixel

    neopixel.NeoPixel(pin0, 16)

    def show_pixel(position, wait):
    neopixel.set_colour(position, 0, 0, 64)
    music.pitch(440 + position * 16, wait)
    neopixel.set_colour(position, 0, 0, 0)

    def run():
    pos = 0
    score = 0
    pixels = [x for x in range(16)]
    pause = 100

    while True:
    if button_a.is_pressed():
    for pos in pixels:
    show_pixel(pos, pause)
    pos += 1
    for pos in pixels[::-1]:
    show_pixel(pos, pause)
    pos -= 1
    score += 1
    pause -= 5“{}”.format(score))

    display.scroll(“Score: {}”.format(score))

    while True:
    if button_a.is_pressed():

  5. I would like the kids in our code club to use this as opposed to the web version as this is a really useful micropython editor.

    Do you also have a 32bit version for Linux?
    The code club here only has 32 bit Linux.
    So far I have only found the 64bit version that unfortunately is not compatible with the Linux version we use.

    1. I don’t have a copy of it, but I have asked the folks that would if there was a technical reason it was possible 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.