MakeCode

Getting Familiar

The code for this project was created using Microsoft MakeCode for Adafruit, a web-based code editor. MakeCode provides a block editor, similar to Scratch or Code.org, and also a JavaScript editor for more advanced users.

If you'd like to learn more about MakeCode, this guide is a good place to start.

Click the button below to enter the portal to interact with the code for this project

How to Upload Code

To upload code, connect Circuit Playground Express to your computer using a 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 removable drive called CPLAYBOOT. 

Click the Download button to download the .uf2 file to your computer, and drag 'n drop that .UF2 file onto the CPLAYBOOT drive in your computer's file explorer or finder.

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!

What's Happening?

First, in the on_start loop we tell Circuit Playground Express that a NeoPixel strand with 20 pixels is going to be connected at pin A1. Then we tell it how bright we want our lights to be (as bright as possible). 

Then in the forever loop, we tell the strip to show one frame of the "rainbow" animation at a time, with a 5 millisecond delay between each frame.

If you'd like to play with this code, click "Edit" and a new window will open in which you can create your own version.

MakeCode is fun to work with and easy to customize, allowing you to get some great results with just a little trial-and-error. 

Changing the NeoPixel Animation

If you'd like to change or add anything to your light show, you will find the NEOPIXEL section becomes available after you click on the LIGHT section. 

Click on the LIGHT block at the top of the list.  The code in this block deals with the Circuit Playground's onboard lights. When you click this tab, a new block called NEOPIXEL appears. This is the block you want.  The options in this block deal with any light strips extraneous to the NeoPixels already onboard the CPX and provide many fun options for animating your NeoPixel strip. 

To reveal the NEOPIXEL section in MakeCode, first click on LIGHT

Troubleshooting

Problem: My NeoPixels won't light up!

Solution: Make sure that your Circuit Playground Express is connected to a power source (anywhere between 3V-5V is safe). If you're using a AAAx3 battery pack, check that the switch on the battery pack is set to "ON".

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

Solutions:

  • Be sure you have a Circuit Playground Express.  The Classic will not work with MakeCode.
  • 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.  
  • With the Circuit Playground 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.

This guide was first published on Jan 29, 2019. It was last updated on Jan 29, 2019. This page (MakeCode) was last updated on Dec 05, 2019.