If you'd like to learn more about MakeCode, this guide is a good place to start.
MakeCode is fun to work with and easy to customize, allowing you to get some great results with just a little trial-and-error.
To upload code, follow these instructions:
1) Connect your 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 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.
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!
The code for this project uses a bit of logic to create two modes for the NeoPixel ring based on the position of the slide switch. In the first section of the blue
if statement we can see that
if switch right then the brightness should be turned all the way up and the NeoPixel strip set to match the color detected by the light sensor onboard Circuit Playground Express.
In the second part of the blue if statement, the
else if not switch right command tells Circuit Playground Express to follow the contained instructions only if the slide switch is moved to the left (i.e. not right) position. A new variable, "value", is created to measure the analog value of the potentiometer connected to pin A2, which can then be used to control the brightness of the NeoPixel ring, using the
strip set brightness value block.
For more information on using potentiometers take a look at this guide.
With the switch in the right position, you should be able to hold up different colors to the light sensor and watch how the NeoPixels react as CPX attempts to detect and match the color as best it can.
If you'd like to play with this code, click "Edit" in MakeCode and a new window will open in which you can create your own version.
For this project we are using RGB+W pixels. Depending on what kind of NeoPixels you're using you may need to edit the format in the
on start block to get the colors to display correctly.