Getting Started with MicroPython and the SparkFun Inventor's Kit for micro:bit

Contributors: LightningHawk
Favorited Favorite 2

Introduction to MicroPython

MicroPython is an open source interpreter for the Python programming language developed specifically for microcontrollers. In this experiment guide, we will show you how to get started using MicroPython with the popular micro:bit board and our SparkFun Inventor’s Kit for micro:bit.

1 Retired
Note: This experiment guide assumes you have experience with programming. If you have never used a programming language before, we recommend checking out the MakeCode version of this guide. MakeCode is a drag-and-drop editor that is great for beginners of all ages learning to program.

When you’re done with this guide, you’ll have the know-how to start creating your own projects and experiments with MicroPython for micro:bit!

Using MicroPython

MicroPython is just an interpreter, so it does not include a space to write and edit code. Luckily, there is an editor we can use to write our Python code. Before you get started, you’ll need to download Mu. Mu is a simple code editor for beginners that runs on Windows, OSX, Linux and Raspberry Pi.

A major benefit of using MicroPython is the interactive REPL. REPL stands for read-evaluate-print loop, which is a very long way to say you can execute code live without compiling it first and then uploading it after. To get the REPL working on Windows, you’ll need to have the Serial Driver for mbed installed.

The applications for Python are extensive, and the advantage to using Python over other programming languages include interacting with other languages and platforms, third-party modules, extensive support libraries, user-friendly data structures and, of course, it’s open source.

Some known issues with using Mu and micro:bit currently are not being able to import third-party modules, not being able to use interrupts, and not having a decent way to map numbers of one range to another. Since importing third-party modules is not supported, we will be copying and pasting the source code in the current Mu MicroPython file. As with learning any new language, Python requires time, patience, self-study and a lot of examples! Keep at it, and we will be here to help you along the way.

Project Files

To download all of the files needed to follow along with all of the experiments, click the button below.

Download the Project Files!

Software Options

To use MicroPython with the micro:bit, there are a few different options.

Suggested Reading

If you have never worked with electronics before, we recommend you be somewhat familiar with the concepts in the following tutorials:

  • Voltage, Current, Resistance, and Ohm’s Law — The most basic concepts in electronics and electrical engineering. Get very familiar with these concepts, as they will be used throughout your electronics adventure.
  • What is a Circuit? — In this guide, we will be building a variety of circuits. Understanding what that means is vital to understanding the Inventor’s Kit.
  • How to Use a Breadboard — First time working with a breadboard? Please check out this tutorial! It will help you understand why the breadboard is great for prototyping and how to use one.