Now that you've set up your hand, you can program it with Microsoft MakeCode for Adafruit!
MakeCode is a web-based code editor designed for beginners that is amazingly simple to learn. You can use it online -- there's no need to download anything. You can build programs quickly with drag-and-drop blocks, similar to Scratch.
If you're new to MakeCode and CPX, you can learn more by checking out the Adafruit MakeCode Guide.
- Start simple. Make sure your light flashes on and off before adding complicated patterns or more actions.
- Use an
on [button A][click]
block from the INPUT menu to write your code. It is an easy and reliable method to start your code running, whether you are testing your code with either the on-screen simulator or your real-life circuit. After you've confirmed that the code works, you can change the kind of input or move the code to aforever
loop. - To make sure you code has run when it won't show on the simulator (like the external LEDs), or to keep track when you have several stacks of blocks going at the same time, add a
play sound [ba ding]
block from the MUSIC menu to your stack. Use different sounds for different stacks, or different points in the stack, so you know where the code is as it runs. - You can add a comment to a block by right-clicking on it, then writing in notes to help you remember what it does.
- Give your program a name before you download it to your CPX, save it to your computer, or create a sharable link on the MakeCode website. That will help you find it later!
Coding the Onboard NeoPixel LEDs and Music
Making the ring of LEDs right on the CPX board glow or change color is amazingly simple, and will add another element to the external lights you are going to code.
Just click on the LIGHT menu at the top of the list, choose one of the blocks, and drag it into the workspace. When you place it inside a block from the INPUT or LOOPS menu, you can make it play. There are preprogrammed animations as well as blocks that let you set the colors yourself.
Use pause
blocks from the LOOPS menu to set how long a light should be lit or dark.
The musical notes are found in the MUSIC menu, where you will also see preprogrammed sounds and a melody block that lets you create a sequence of eight notes by clicking on a grid of colored squares. Easy peasy!
The program at the top of this page makes the onboard LEDs flash orange while playing notes. You can view, edit, and run it by going to this link or clicking the button below.
Then go on to see how to program the external LEDs you have added to the CPX!
Text editor powered by tinymce.