Installing the Android application

Come to this page on your Android device and click the Link to Play Store. Or, if you have the Barcode Scanner installed, scan the QR code to the left.

Mounting the storage as writable

We can't use the standard USB storage method to save code to the Circuit Playground Express because Android does not have support for the type of filesystem formatting used by the board. In order to work around this the application, will use the REPL to load and save the code using Python statements like and f.write().

You can only have either your computer edit the CIRCUITPY drive files, or CircuitPython. You cannot have both write to the drive at the same time. (Bad Things Will Happen, so it's one or the other.)

In order for the REPL to be able to save your code, you will need to have the storage mounted as writable. Whenever the storage is mounted as writable for the REPL, it will be not writable using the normal USB storage method.

In this tutorial, we will set it up so that the board will check the Circuit Playground Express on-board slide switch and set the storage mount accordingly. This way, we can switch back and forth easily between standard USB storage, and save from the Android app via REPL. If you want to learn more about using the storage or using the storage on a board besides the Circuit Playground Express, see this guide. Note that the board must support CircuitPython.

To accomplish this, we'll need to edit the file on the Circuit Playground Express. You'll need to do this step from your computer. If you don't already have a file, it's no problem--just create one.

Copy this code into your file:

import board
import digitalio
import storage
switch = digitalio.DigitalInOut(board.D7)
switch.direction = digitalio.Direction.INPUT
switch.pull = digitalio.Pull.UP
# Mount the storage based on the on-board switch
# Switch position right for REPL/Android app
# Switch position left for normal USB Storage
storage.remount("/", switch.value)

As the name suggests, only gets executed when the board first boots up. Because of this, you must unplug the board from power, then flip the switch to the desired position while it's unplugged. After you've flipped the switch, you can plug the board back in. 

If the switch is in the left position, the board will behave like the standard USB storage / flash drive. 

If the switch is in the right position, the board will be mounted so that the Android application can save your code with REPL.

This guide was first published on Dec 18, 2018. It was last updated on Mar 08, 2024.

This page (Preparation) was last updated on Mar 08, 2024.

Text editor powered by tinymce.