[Microbit-Python] microbit_stub - a Python module to test micro:bit Python programs

Nick Cook nick.cook at newcastle.ac.uk
Tue Jun 14 13:22:28 EDT 2016


I have released my microbit_stub module on github. It is  a Python module to test microbit micropython programs without needing a physical micro:bit, completely offline. You can do what you will with it from the github home:

<https://github.com/casnortheast/microbit_stub>https://github.com/casnortheast/microbit_stub

It as a textual "emulator" of the micro:bit (as defined by the microbit micropython API) that allows you to take a microbit micropython program and test it using the microbit_stub module. It is intended to be useful if you do not have a micro:bit, or if you are not using the offline mu editor with a REPL window and need something more than the error feedback on the micro:bit screen. Or it can just be used by pupils (and others!) to test program syntax and logic before running on the micro:bit (or after if they get an error and cannot easily work out what the problem is). Programs using this module should run in any Python IDE (including IDLE) and at the command line.

Some documentation, tests and example programs are on the github page (including simple support for simulation of microbit state).

It should work with any microbit program by changing the import statement to import "microbit_stub" instead of "microbit". There is also a sub directory in the release that uses "microbit" as the module name and, therefore, does not require any change to an existing program (you will see from the README that I am not undecided about which approach to take :).

I may at some point extend the module to provide a graphical emulation (or the option of it). Peter Dring has produced a Web-based micro:bit Python simulator that could also be of interest (it is intended for a different usage to this module) - see: http://community.computingatschool.org.uk/resources/4479. And there is David Whale's minecraft micro:bit, see: https://github.com/whaleygeek/mc_microbit. There may be others.

Nick

Nick Cook
Lecturer in Computing Science at Newcastle University
and lead of CAS North East: http://casne.ncl.ac.uk/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20160614/c87cf903/attachment.html>


More information about the Microbit mailing list