Spooky Spider Using Adafruit CPX
This is a cute spider that shines halloween spirit! This design features halloween colored lights and plays a spooky tune to go along with the lights. This can be a simple prop addition to a costume or it can be a showpiece decoration for your living space.
Supplies
1x Adafruit Circuit Playground Express
2x Googly Eyes
2x Brown Pipe-Cleaners
1x USB A to Micro USB wire that supports data transfer
*You will also need access to a computer*
Open Code Editor
Go to makecode.adafruit.com on a computer and open a new project.
Code the Lights
From the LIGHT section, drag a "set brightness" block and place it inside the forever loop block. In the "set brightness" block, enter 255. This will set the brightness to the max. If you wish, you can lower the brightness. Then, drag a "show ring" block from the LIGHT section. The color pattern I chose, in counterclockwise order, is green, purple, orange, white, purple, green, orange, white, green, purple. I chose these colors because they look good together and are common halloween colors, but you can change the pattern/colors if you wish.
Code the Music
Since we will be coding the song based on sheet music, the code will be simple yet tedious to create. What we have to do is we have to read each note and place a separate code block for each corresponding note. In my build I have used the free piano song Scary Night by Julie A. Lind, but you can really use any piano song you choose. Since you read sheet music as individual notes combined together, what you do to code the music is you take the block from the music tab that says "play tone at__ for __ beats". For every beat in the sheet music you fill in the corresponding note into the block, and in between the individual notes you need to add a pause block for 50 ms, just to account for human processing time, because otherwise the machine will play all the notes at once. For example, If the sheet music says 2 beats on A, then 1 beat on C, and then 1/2 beat on B, you would code that as: play tone at A for 2 beats, then play tone at C for 1 beats, and then play tone at B for 1/2 beats. Also, set the volume to 255 (max) because the speaker on the cpx is very quiet. Also, you do not have to use the "on button A click" command; you can use any other loop to keep your code running. I have attached an image and pdf of my code I wrote based on the sheet music, so if you do not want to use your own song or you do not want to translate a whole page of sheet music, you can use my code for an easy spooky song.
Downloads
Download the Code
Now, plug in the USB A to Micro USB cable into your computer. Attach the CPX on the micro USB side of the cable. On Microsoft Makecode download your final version of the code. Then, drag the UF2 file (the code) into the location in your file browser that says CPLAYBOOT. Your CPX should automatically boot up the code, and know you can unplug the CPX so we can decorate it!
Assemble the Spider
First, tape the CPX onto the side of the battery pack that has the on/off switch. Then, stick the 2 googly eyes to the front of the battery pack. Then, cut each of the brown pipe cleaners into 2 parts. Now that you have 4 pieces, tape the 4 pieces parallel to each other onto the bottom of the battery pack. Then, curl up the pipe cleaners so they look like spider legs. If you wish, you can add extra elements so that your spider looks extra festive and unique!
You're All Set!
Put your spider on display where you can show it to others or add it to your costume as a great prop! I have attached the pdf of the complete code of the spider into this step in case you need to reference it! I hope you had fun! To watch a video of the spooky spider in action, click here!