Using the Mu Editor

For this project I'm going to use the Mu Editor, a simple Python code editor tailored to beginners that runs on MacOS, Windows and Linux. If you don't have Mu installed, you can download a copy and learn how to install it on your computer by clicking below:

Step by step instructions for Mu are listed here in the Welcome to CircuitPython Guide.

Before you run Mu, connect your board to your computer with a USB cable, so that Mu can recognize it right away when it starts. Note that if you are using a Microsoft Windows 7 or 8 computer, you will need to install the Adafruit drivers for your board if you haven't done that yet. Drivers are NOT needed for Windows 10.

Mu uses "modes", a set of predefined configurations tailored to specific uses. The mode is changed by clicking on the first toolbar button on the left, appropriately labeled Mode. Depending on the version of Mu that you are using, you are going to find either an "Adafruit" mode, or a "CircuitPython" mode. Make sure this mode is selected.

gaming_mu-mode.png
CircuitPython mode in the Mu editor

Click on the Serial button and then press Ctrl-C (press and hold the Ctrl key, then press the letter C). The Ctrl-C key combination is used to interrupt the code that is currently running on the board. You should now see a message that reads "Press any key to enter the REPL. Use Ctrl-D to reload". Press enter or any other key (except Ctrl-D!), and that should bring you into a Python prompt that looks more or less like this:

Download: file
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.2 on 2019-06-27; Adafruit CircuitPlayground Express with samd21g18
>>>

This prompt is called a REPL, which is short for Read-Eval-Print-Loop. Here you can type code and have it executed immediately by the CircuitPython interpreter running inside the board. The REPL is an invaluable tool while writing code, since you can use to test things out with immediate feedback. Also, if the code that you write has errors, the REPL will show you information that can be useful in diagnosing and fixing the problem. I recommend that you keep the REPL window open at all times while working with a CircuitPython board.

Try running a simple Python command in the REPL. For example:

Download: file
>>> print('Hello from CircuitPython!')
Hello from CircuitPython!
>>>

Before I begin with the game, let's spend a moment thinking about the code that is currently stored in your board, which will soon be replaced. I assume you don't want to lose this code, so now is a good time to make a backup copy. In your computer you should have a disk labeled CIRCUITPY which represents the board's storage. Inside this disk, you will find a file named code.py. You can drag this file into your computer to make a copy of it, or if you prefer you can rename it in place to something such as code-backup.py.

This guide was first published on Jul 24, 2019. It was last updated on Jul 24, 2019. This page (Using the Mu Editor) was last updated on Sep 16, 2019.