Getting started with the BBC Microbit

Tiny open hardware board makes it easy for anyone to learn to code with fun projects.
148 readers like this.
BBC Microbit board

Don Watkins

Whether you are a maker, a teacher, or someone looking to expand your Python skillset, the BBC:Microbit has something for you. It was designed by the British Broadcasting Corporation to support computer education in the United Kingdom.

The open hardware board is half the size of a credit card and packed with an ARM processor, a three-axis accelerometer, a three-axis magnetometer, a Micro USB port, a 25-pin edge connector, and 25 LEDs in a 5x5 array.

I purchased my Microbit online for $19.99. It came in a small box and included a battery pack and a USB-to-Micro USB cable. It connects to my Linux laptop very easily and shows up as a USB drive.

BBC Microbit board

Start coding

Microbit's website offers several ways to start exploring and coding quickly, including links to third-party code editors and its two official editors: Microsoft MakeCode and MicroPython, which both operate in any browser using any computer (including a Chromebook). MakeCode is a block coding editor, like the popular Scratch interface, and MicroPython is a Python 3 implementation that includes a small subset of the Python library and is designed to work on microcontrollers. Both save your created code as a HEX file, which you can download and copy to the device, just as you would with any other file you are writing to a USB drive.

The documentation suggests using the Mu Python editor, which I wrote about last year, because it's designed to work with the Microbit. One advantage of the Mu editor is it uses the Python REPL (read–evaluate–print loop) to enter code directly to the device, rather than having to download and copy it over.

When you're writing code for the Microbit, it's important to begin each program with From microbit import *. This is true even when you're using the REPL in Mu because it imports all the objects and functions in the Microbit library.

Beginning a Microbit project

Example projects

The documentation provides a wealth of code examples and projects that got me started hacking these incredible devices right away.

You can start out easy by getting the Microbit to say "Hello." Load your new code using the Flash button at the top of the Mu editor.

Flash button loads new code

There are many built-in images you can load, and you can make your own, too. To display an image, enter the code display.show(Image.IMAGE) where IMAGE is the name of the image you want to use. For example, display.show(Image.HEART) shows the built-in heart image.

The sleep command adds time between display commands, which I found useful for making the display work a little slower.

Here is a simple for loop with images and a scrolling banner for my favorite NFL football team, the Buffalo Bills. In the code, display is a Python object that controls the 25 LEDs on the front of the Microbit. The show method within the display object indicates which image to show. The scroll within the display object scrolls the string "The Buffalo Bills are my team" across the LED array.

Code for Microbit to display Buffalo Bills tribute

The Microbit also has two buttons, Button A and Button B, that can be programmed to perform many tasks. Here is a simple example.

Code to program Microbit buttons

By attaching a speaker, the device can speak, beep, and play music. You can also program it to function as a compass and accelerometer and to respond to gestures and movement. Check the documentation for more information about these and other capabilities.

Get involved

Research studies have found that 90% of teachers in Denmark and students in the United Kingdom learned to code by using the Microbit. As pressure mounts for programming to become a larger part of the K-12 school curriculum, inexpensive devices like the Microbit can play an important role in achieving that goal. If you want to get involved with the Microbit, be sure to join its developer community.

Tags
User profile image.
Educator, entrepreneur, open source advocate, life long learner, Python teacher. M.A. in Educational Psychology, M.S. Ed. in Educational Leadership, Linux system administrator.

2 Comments

This is excellent. It's come along right at the correct moment for me as I'm getting one for my children to start coding with. Thanks!

Great! I am really excited by the possibilities afforded by this neat little device. I'm teaching an Intro to Raspberry Pi and Python coding class and I've gotten one of these for each of my students to extend their learning.

In reply to by dncnmckn

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.