A Python module that emulates the BBC microbit as defined by the microbit micropython API.
Created by Nick Cook
last edited Jun 01 2016 by Nick Cook
This Python module is based on the microbit micropython API defined as part of the BBC microbit project.
The aim is to provide an implementation of the microbit micropython API that can be used to test a microbit micropython program without having to have a physcial microbit connected. This is similar to the in-browser microbit emulations for other programming languages provided at http://microbit.co.uk/.
If a student develops using the Web based Python editor, feedback with respect to bugs in their program is via a Python error message scrolling across the physical microbit screen. These are quite difficult to read and could become a barrier to development. Development in Python is likely to lead to simple syntax errors (indentation etc.) that only become apparent when an error message is displayed on the microbit screen. The hope is that it will be easier for students to find and correct bugs if they have more readable error output.
The offline mu micropython editor has a REPL shell that, if connected to a microbit, will display error output in the shell and support easier debugging. Even so, there may be some benefit in being able to trace and debug a program without connecting to the physical microbit.
This module supports disconnected program development by emulating most of the microbit’s functionality (see the “What is emulated” section of the GitHub README for more details). Emulation output is text to the console, which means the module can be used in many programming environments.
The module provides mechanisms to simulate changes to the state of the microbit (e.g. reading and writing to pins).
It allows testing of both the syntax and logic of microbit micropython programs.
The microbit_stub code is licensed under the MIT open source license for consistency with the microbit micropython license.
The zip file attached to this resource is a snapshot of the microbit_stub GitHub repository.
To keep up to date with the module, its documentation and other files associated with the module it is recommended to download or contribute to the GitHub repository at: