MakeCode is an easy way to get up and running with the Circuit Playground. No prior coding knowledge is needed, and it's an easy way to experiment and learn to think like a coder. You just drag and drop code blocks, like building with Lego. MakeCode makes coding fun!
Head over to this Intro to MakeCode guide for more info on getting started with MakeCode.
- Open the project with the button above and click the blue DOWNLOAD button near the bottom of the project.
- Plug your Circuit Playground into your computer via its USB port and click the "reset" button. All the lights will turn green and your Circuit Playground will appear as a drive on your computer called CPLAYBOOT.
- Drag the code you just download onto this drive to program the Circuit Playground -- like putting files on a USB stick. That's all you need to do.
Note: If you plug in the board and you see a drive called CIRCUITPY appear, press the reset button again (double-click) to get to CPLAYBOOT.
The tiny slide switch on the face of the Circuit Playground turns the light strand on or off. Slide right for on, slide left for off. (So, if you just downloaded the code and you don't see anything happening, flip this switch! You might just be in "off" mode.)
This code has four different modes. Click button A to cycle between them:
- Rainbow: an animated LED rainbow. Who doesn't love rainbows?
- Rainbow Fade: the lights are all the same color and fade through the rainbow as a unit
- Solid: Pick a color, any color ya want!
- Twinkle: Lovely glittery white twinkles
Button B is our variation button. Click it to vary the speed of the rainbow and twinkle animations, and the color (hue) of the solid animation. There are seven speed levels, from fast to slow, and the hue will just keep changing and rotating each time you press the button.
You can add your own modes, give yourself more speed variations, or set it to start up on your favorite mode. The possibilities are endless! Poke around and change some stuff, and if it stops working you can always come back here and start fresh. Make it yours.
The green box on the left contains two blocks:
on start and
forever. These are found under the LOOPS tab at the left. Anything in the
on start block runs just once, when the board first powers up. Anything in the
forever loop runs over and over, forever.
On Start Block
The first line sets up our light strand. If you have more than one strand daisy-chained, change the
Next, we define our variables.
If you add or remove modes, change
To select a different start-up mode, change
You can also change the starting
Here is where we set up the order of our modes. If you want to add more modes you can do it here by clicking the + button at the bottom and calling more functions. Be sure to increment the mode number in each block you make, and don't forget to change
I really like having
The blue box in the middle contains our functions. These are the actual LED modes themselves, which we call in the forever loop. You can add as many functions as you like.
This block is where we tell the CircuitPlayground to scroll through the modes each time button A is clicked. When it reaches the last mode (defined by the
Button B is where we've created our variations. I'm varying speed and color, but you could also vary brightness or saturation or any other variable you can dream up.
Try changing the numbers around to customize how many speed levels there are or how much the color changes each time the button is pressed.
There are also other triggers available -- you can trigger a mode change or variation when you shake or move the CircuitPlayground, or whenever a loud sound is heard, or a whole host of other options. Look under the INPUT tab to see them all.
This is an easy way to make your project react to its environment. Make the crystals change color whenever you clap your hands or jump up and down!
Here's where we turn the lights on and off with the slide switch. We've done this by changing the brightness to 0 or back to 255, so if you want to change the overall strand brightness be sure to change it here as well as in on start.
Doing it this way means the Circuit Playground will "remember" the light mode and variation you were in when you turn the lights back on. Cool!
However, remember that the whole project is NOT turned off when the slide switch is in the off position. The board is still awake and using power, so if you've got a battery powered project, this mode will slowly drain your battery. Turn it off with the switch on the battery pack or unplug your battery when you're ready to leave it off long-term.
If you are having trouble, here are a few things to check:
- Is your slide switch in the "off" position? If you download the code and nothing happens, flip the switch the other way to see if that fixes things.
- Are you connected to pin A1 with your data wire? Double check your wiring to be sure it matches the diagram.
- Did you connect to the IN end of the strip? The lights should be face up when the Circuit Playground is face up, without any twist in the wires. If they're face down, you've connected to the wrong end of the strip. Switch it around and try again.
- Are you using a Circuit Playground Express instead of a Circuit Playground Bluefruit? This code will work with the Express, but you need to select it in the MakeCode window. Click the
...button next to the
Downloadbutton and select Choose Hardware to switch boards.
If you still can't get it working, head over to the Circuit Playground BlueFruit Intro Guide for more help and suggestions.