Working With Files

When you write Python code in CodeSpace it is stored on your CodeX filesystem. Your Python code can also create, read, and write files of its own.

You’ve probably noticed when you plug your CodeX in to the USB port of a computer that it shows up as a mass-storage device, like a flash drive. This can be really useful! For example, your Python code can log sensor data to a CSV file, which you can later access with a PC through the USB-attached filesystem.

By default the USB-accessible filesystem is read-only, so a PC can’t for example copy new Python files onto the CodeX, or edit existing ones. But if you want to do such things, there’s a way to change it so the filesystem can be written to “like a flash drive”. Note that while it’s in this mode your Python code (and CodeSpace) will see the filesystem as read-only. You can’t have it writable from both directions.

../_images/Codex-A_L.jpg

The following bootup key-combination will make the filesystem writable as a USB mass-storage device until the next reset of CodeX.

  1. Press and hold buttons A and L and keep holding them down

  2. Briefly press the RESET button next to the BATT switch.

  3. Keep holding buttons A and L until you see the red LEDs light up from 0 to 3 in right-to-left order.

  4. You will see a double-flash of ALL red LEDs to confirm the filesystem is in USB-writable mode.