What is MakeCode?
MakeCode is a web based code editor for physical computing made by Microsoft.
What does that mean for you? It means you can program your Circuit Playground Express to do almost anything you can dream up right from a website! You can code with blocks similar to the language Scratch, or you can do more advanced coding with Javascript. We'll be sticking to the block-based programming for this project.
More on MakeCode for Adafruit boards here.
Install the MakeCode CRICKIT Extension
Before we start programming, let's make sure you have the CRICKIT extension installed in MakeCode.
Detailed instructions on how to do that can be found in this guide.
Create a New Project with MakeCode
Head over to https://makecode.adafruit.com/ and create a new project.
What's going on in the code above?
- When button A is clicked:
- the brightness of the NeoPixels is set to a value of
134
- all NeoPixels are set to a magenta color
- the motor is selected for motor pin
1
and is set to13%
- the brightness of the NeoPixels is set to a value of
- When button B is clicked
- the brightness of the NeoPixels is set to a value of
134
- all NeoPixels are set to a blue color
- the motor is set to stop with
0%
- the brightness of the NeoPixels is set to a value of
*Note: the % value of the motor can be negative if you wish for the swings to rotate the opposite direction. Switching the wiring of the motor will have the same effect.
Uploading the code
Now that we have the code for the project, we need to upload it to the Circuit Playground Express.
Let's name our file and download it.
- Choose a name at the bottom of the page.
- Then click the pink Download button.
Follow the directions and connect your Circuit Playground Express to your computer via the usb cable. Click the Circuit Playground Express Reset button once to go into programming mode (all NeoPixels will turn green).
In some cases, you may need to press the reset button twice to get into programming mode.
Next, look for the file in your downloads folder and drag it onto your CPLAYBOOT drive that should have showed up in your file manager/finder when you plugged in your board and entered programming mode.
You should now see the CPLAYBOOT drive disappear.
Power up CRICKIT
Connect CRICKIT to power with the 5V DC power cable
The code should now be running so try it out!
If you are having issues getting things to work check out this extended guide here.
Try changing the % value of the motor to various values and see what happens!
Text editor powered by tinymce.