This project uses MakeCode to light up the project. MakeCode is a free web-based app that lets you control the lights on your Circuit Playground board. Choose your colors, make the lights move (this is called "animating"), control the motion speed and brightness and much more.
Go to https://makecode.adafruit.com/ and select "New Project".
Here's your work environment. You can see the Circuit Playground with its lights simulated on the left. In the middle are tabs containing all the code blocks you can use, and on the right side is the workspace where you'll build your code.
You may see a block that says
forever, but no block that says
on start. Let's add this one since we want to use both.
Click the LOOPS tab and find on start. Drag it into your workspace above forever.
Anything we put inside the
on start block will happen one time, when you power up your board. Anything we put in the
forever block will run over and over, forever.
Let's choose some colors for our lights! First let's tell the board we want the lights to be very bright. Click the LIGHT tab and find set brightness. Drag it inside your
on start loop and drag the slider all the way to the right, so it reads 255 - that's as bright as it can go.
Now, when we power up the board, it will know to turn the lights all the way up.
show ring into the
forever block. You'll see the lights on the emulator turn bright red.
Click the color wedge, then click one of the light circles in the
show ring block to choose a color for each light. This is fun! Make the lights shine in your favorite colors.
If you're happy with how it looks, you can click Download and skip down to the Download section to see what to do next. Or, if you want to learn how to make the lights move, read on...
MakeCode has six different pre-programmed LED animations you can pick from. Open your LIGHT tab again and scroll down until you find
show frame of animation. (There's also one called
show animation up higher - we're not using that one right now).
show ring block from your
forever block and move this one in there instead.
Open the dropdown menu and you'll find six different animations to pick from. Select each one and watch the emulator on the left to see what it does. Choose your favorite. I like the rainbow animation for this project.
The rainbow animation is really cool, but it moves a little bit too fast for a lamp project. I want a nice slow rainbow that doesn't make me feel so frantic. We can slow it down using the
pause block, which is under the LOOPS tab. Choose different values from the dropdown until the animation moves at the speed you like.
Once you're happy with your code, give it a name, and click the Download button to download the file to your computer.
Let's test to see if it's working.
- Plug your Circuit Playground Express into your computer with a USB cable.
- Click the reset button.
- Green lights will appear on the Circuit Playground's face and it will appear in your list of devices, called CPLAYBOOT.
If you don't see this, try double-clicking the reset button instead of single-clicking.
Click the pink Download button on your MakeCode screen and the code you just made will download to your computer. Drag it onto the CPLAYBOOT device.
Plug the light strand into power and you will see a pretty rainbow animation. Hooray!
If you want to change something, no problem. You can reprogram your Circuit Playground as many times as you like. Experiment and play around, and see what you can get it to do!
Things to Try
- Make two animations play, one after the other
- Make your favorite color lights come on for a few seconds, then play an animation
- Look under the INPUT tab to make your Circuit Playground change when you shake it or shine a light on it, or clap your hands. This board has a whole bunch of cool sensors that can make your lights interactive. (This is a bit more advanced but there are lots of guides in the Adafruit Learning System that show how to do this!)
If you're having trouble or are getting frustrated, no worries. Here's the completed project that you can play with directly. Just click Download and drag it to your board.