Getting started with MakeCode

This project runs a simple MakeCode sketch and is easy to play with if you want to make changes.

Microsoft MakeCode for Adafruit is a web-based code editor that provides a block editor, similar to Scratch or, and also a JavaScript editor for more advanced users.

If you've never used the Circuit Playground Express with MakeCode before, this guide is a good place to start.

The Code

The code is shown below. For browser viewing, you may need to enable content. For example, in Chrome, click "Show Embedded Content" as the material is fed not from Adafruit but from Microsoft's MakeCode site.

To download the code, click the download link at the bottom of the window. To edit the code in MakeCode, click the box with arrow icon in the upper right corner of the window.

How to Upload Code

To upload code to Circuit Playground Express, follow these instructions:

1) Connect your Circuit Playground Express to your computer using a known, good data+power micro USB cable and press the small reset button in the center of the board. All the LEDs will flash red briefly, then turn green. Your computer should now show a removable drive called CPLAYBOOT. 

2) Click the Download button in the code window below to download the .UF2 file to your computer.

3) Now drag and drop the .UF2 file onto the CPLAYBOOT drive in your computer's file explorer or finder.

Once the file is dragged onto CPLAYBOOT, the drive will automatically eject itself (your computer may give you a "failed to eject drive correctly" error, you can ignore this). The code is now on your Circuit Playground Express and ready to run!

Note: If you get a drive named CIRCUITPY, no worries! Press the reset button twice to get a flash drive named CPLAYBOOT. The project will not run if copied onto the CIRCUITPY drive as it is for CircuitPython.

What Does This Code Do?

The code for this project uses some built-in capacitive sensing abilities to detect when the sword is being held and when it's put down. In the on start statement we can see that set strip to block defines the length of the NeoPixel strip and which pin will control it (in this case A1). It also simultaneously sets the brightness of the NeoPixel strip to 0 while calibrating the sensitivity of the capacitive touch pad A7.

In the first pink statement, the on touch A7 down command tells Circuit Playground Express to bring the brightness of the strip up to 200 and play the rainbow animation when it detects a change in capacitance.

Below, the on touch A7 up command tells the strip to fade its brightness slowly when the sword is no longer being touched, resulting in a return of the measured capacitance to baseline.

Lastly, some functionality is given to button A, allowing the user to recalibrate the touch sensitivity without needing to restart the board.

Your Circuit Playground Express will take a few seconds to calibrate after being turned on. For best results don't touch while it's calibrating!


Problem: My Circuit Playground Express doesn't show up as CPLAYBOOT


  1. Be sure you have a Circuit Playground Express.  The Circuit Playground Classic will not work with MakeCode.
  2. If you get a drive named CIRCUITPY instead, press the reset button twice in succession to get to CPLAYBOOT.
  3. Some USB cables are "charge-only" and won't pass data. Try using a different USB cable and try using a different USB port on your computer.  
  4. With the Circuit Playground Express plugged into your computer with a micro USB cable, click the small reset button in the center of the board. The lights should all turn green. If they don't, try double-clicking the reset button.

If things still aren't working, head over to the Intro to Circuit Playground Express guide for more suggestions.

For more information on using capacitive touch take a look at this guide.

This guide was first published on Sep 18, 2019. It was last updated on Sep 18, 2019.

This page (MakeCode) was last updated on Sep 12, 2019.

Text editor powered by tinymce.