Introduction: Star Wars Light With Circuit Playground Express
This light uses Circuit Playground Express to play light and music sequences. The attached touch pads turn on separate light animations and play either The Imperial March (Darth Vader's theme) or the Main Theme from Star Wars. The program code included in this tutorial can be changed to play any musical score and additional touch pads could be added to play further sound/light sequences.
- Circuit Playground Express
- MakeCode online programming platform
- Beverage can
- Exacto knife
- Rubbing alcohol & a paper towel
- Sewing needle (or awl)
- 4 aligator clips
- External speaker with head-phone jack
- 2 nickels (or pieces of copper)
- Material for base (optional)
Step 1: Step 1: Build Your Code
To start, open up Adafruit's MakeCode online platform and start a new project.
The first chunk of code will make the first light sequence. To start, create a forever loop and create a condition block "if true, then" within the loop. Change "true" to "while __ is pressed" from the input blocks section ("touch A2" is used in this code in order to allow for a touch sensor but you can also select the A or B button if you would rather not have an attached sensor to initiate the program). (see image 2)
The second chunk of code will create the accompanying sound sequence. To create the sound sequence, create a series of "play tone at ___ for ___ beat" and insert the notes and beat lengths based on the simple music score for The Imperial March (see image 4). End the second piece of code with a command to stop animations when the other sensor (here it's "touch A3") is pressed. This will make sure that the first light animation will not continue over the second light animation.
See image 8 for the completed second sound sequence (see image 9 for the musical score). Make sure to include a "stop all animations" when touch A2 is pressed to make sure that the second animation will not play over the first when switching between the two.
Step 2: Step 2: Hook Up the External Speaker (optional)
Use two alligator clips to attach the Circuit Playground Express to an external speaker. The board has its own speaker but it will play the music sequences very quietly. Attach one end of an alligator clip to a ground (GRD) hole and the other end to the speaker jack. Attach one end of the second alligator clip to the A0 hole and the other end to the same speaker jack (see image).
Step 3: Step 3: Set Up the Touch Sensors
Attach one end of an alligator clip to the A2 hole and attach the other end to a nickel (or piece of copper).
Attach one end of a second alligator clip to the A3 hole and attach the other end to a second nickel (or piece of copper).
When the program runs, each nickel will act as a touch pad which will start their corresponding light animation and music sequence.
Step 4: Step 4: Make the Light Box
To make the light box, start with a cleaned-out can (see image 1).
Carefully cut off the top end of the can using an exacto knife (see image 2). This will leave a sharp rim. Using a pair of pliers, bend the cut rim down and into the can. This will create a level, non-jagged rim (see image 3).
Draw a design onto the can using a Sharpie. The design should be orientated so that the bottom of the can (the end not cut off) is on top. This design used a basic image of R2D2 (see images 4 &5). Once your design in drawn on, use a sewing needle or awl to poke holes along your drawn lines. Make sure to space them a small distance apart (see image 6). Once you have finished punching the holes into your can, use a paper towel and a small amount of rubbing alcohol to remove the Sharpie marks.
If you would like to create a base, choose a material and trace the circumference of the can's cut end. Cut out the circle that the tracing has created (see image 7). Place the open end of the can into the base. This can now be placed over your Circuit Playground Express (see image 8).
Step 5: Step 5: Turning the Light On
Once the light box is over your Circuit Playground Express, you can turn your board and external speaker on. Touching the nickels should initiate your code. If something is not playing properly, check to make sure that your alligator clips are fastened properly.