Code
Attach USB cable
- Insert the small end of your USB cable into the silver port at one end of the Adafruit Circuit Playground Express.
- Insert the big end of the USB cable into your computer.
Getting started
- Open a browser window to https://makecode.adafruit.com/.
- Click on New Project.
Set the volume and brightness
- Click on the
||loops:LOOPS||
Toolbox drawer. - Drag out an
||loops:on start||
block onto the workspace.
- From the
||music:MUSIC||
Toolbox drawer, scroll down and drag out a||music:set volume||
block and drop into the||loops:on start||
block.
- In the
||music:set volume||
block, set the maximum volume of255
.
music.setVolume(255)
- Click on the
||light:LIGHT||
Toolbox drawer, drag out a||light:set brightness||
block and drop into the||loops:on start||
block. - In the
||light:set brightness||
block, set the maximum brightness of255
.
music.setVolume(255)
light.setBrightness(255)
Play a Sound and Animation
- From the
||input:INPUT||
Toolbox drawer, drag an||input:on shake||
block onto the Workspace.
- In the
||input:on shake||
block, click on the||input:shake||
drop down menu and select||input:tilt down||
.
- From the
||music:MUSIC||
Toolbox drawer, drag out a||music:play sound block||
and drop into the||input:on tilt down||
block. - In the
||music:play sound block||
block, click on the drop-down menu to select a sound effect you want to play.
- You can test out the different sounds in the Adafruit Circuit Playground Express simulator by moving your mouse towards the top.
- From the
||light:LIGHT||
Toolbox drawer, drag out a||light:show animation||
block and drop into the||input:on tilt down||
block.
- In the
||light:show animation||
block, click on the animation design drop-down and select an animation to play. - In the
||light:show animation||
block, click on the500 ms
drop-down menu and select 2 seconds (or 2000 milliseconds) as the duration to play the animation.
Turn off gauntlets
- From the
||input:INPUT||
Toolbox drawer, drag another||input:on shake||
block onto the Workspace.
- In the
||input:on shake||
block, click on the||input:shake||
drop down menu and select||input:tilt up||
.
- From the
||light:LIGHT||
Toolbox drawer, scroll down, drag out a||light:clear||
block and drop into the||input:on tilt up||
block.
input.onGesture(Gesture.TiltUp, function () {
light.clear()
})
- From the
||music:MUSIC||
Toolbox drawer, drag out a||music:play sound||
block and drop into the||input:on tilt up||
block. - In the
||music:play sound||
block, click on the drop-down menu to select a sound effect you want to play when your gauntlets turn off.
Your complete program should look similar to this:
music.setVolume(255)
light.setBrightness(255)
input.onGesture(Gesture.TiltDown, function () {
music.magicWand.play()
light.showAnimation(light.cometAnimation, 2000)
})
input.onGesture(Gesture.TiltUp, function () {
light.clear()
music.jumpDown.play()
})
Test
In the Adafruit Circuit Playground Express Simulator window, test your project by moving your mouse up and down on the Adafruit Circuit Playground Express. You should see the lights turn on and off and hear sounds play.
Download
Click the big pink Download button.
This will save your program as a file in the Downloads folder on your computer. Using your computer’s file explorer, open the Downloads folder, you should see a file there called circuitplayground-Untitled.uf2
. This is your program.
Now, check the Adafruit Circuit Playground Express board that is plugged into your computer via the USB cable, and make sure that all the lights are green. If they are not green, press and release the RESET button in the middle of the board until all the lights turn green.
Using your computer’s file explorer, you should see the Adafruit Circuit Playground Express show up as a USB drive called CPLAYBOOT. Drag and drop (or copy and paste) your circuitplayground-Untitled.uf2
program file from the Downloads folder into the CPLAYBOOT drive.
That’s it! Congratulations on Making and Coding your very own indestructible Legendary Gauntlets.