Free Shipping on Canadian Orders over $150!

Teaching Physical Computing in Computer Science with the micro:bit

The micro:bit is an open source hardware microcontroller that was developed by the BBC for use in computer education.  Since its launch in 2015, the micro:bit has become the go-to tool for experimentation in physical computing.  This page is intended to introduce educators to the micro:bit.  If you have any questions, please contact us; we love the micro:bit and are passionate advocates of the product.  

Safety

Rules for using micro:bit:

Inputs and Outputs

Built-in Inputs:

External inputs:

Outputs:

Programming Interfaces

The micro:bit can be programmed in several different languages.  

MakeCode

MakeCode is a great place to start, especially with younger students.  It is similar to Scatch in that you code with blocks.  It is so easy to use that we prefer it to other options when we are doing a quick project.  Here is a simple example that starts out saying "Hello World" and then continually scrolls "Elmwood Electronic is Great".

To get the code onto the micro:bit, you download the file and then simply drag and drop it onto the micro:bit. 

MakeCode is platform agnostic; you can use it on Windows, Mac, or Linux.  It will work on a ChromeBook as well.

The code base for MakeCode is always growing, and there are code libraries for many of the add-on boards that you can import into MakeCode.  

Python

You can also program the micro:bit in a flavour of Python called MicroPython.

There is an online MicroPython programming interface that works well.  Similar to MakeCode, you develop your code, download the file, and drag/drop it onto the micro:bit.  

As you get more advanced, you might consider using an editor like Mu.  Mu is nice because it is easier to debug code, and you can flash your code directly onto the micro:bit.  

To learn more about MicroPython on the micro:bit, check out these tutorials and the official documentation.   

MU editor:

 

Example MicroPython code:

Displaying a single character:

display.show("A")
display.show(Image.HAPPY)

Displaying strings or text:

display.scroll("Hello")
display.scroll("Score:" + str(score))   #convert number "score" to a string

Clear the display:

display.clear()

 

Additional resources

Special thanks to Grant Hutchinson and his presentation from ACSE 2019 for inspiring this page.