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
  • Pliers
  • Sharpie
  • 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.

Create an "on start" block and set the tempo to 30 (see image 1). Set the hue by going into Javascript and adding "let hue = 0" (see image 3).

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)

Continue building the code as seen in image 2. Create a new variable "hue" in order to change hues in the light sequence. Create a new variable (here it's called "j") in order to allow the hue change to rotate around all of the LEDs (where 0 is your first light and 9 is the last light in the sequence). A pause is added to allow you to see the lights progressively shifting. The block coding options only allow for pauses to be as short as 100ms. If you would like the pause to be shorter, you have to edit the duration using Javascript within the parentheses after "pause" (see image 3). Use a "set__ to___" and insert a "hue" variable and a math function. The math function will allow you to determine how quickly the hue transitions (this is set by the number 2 in the example code) and what range of hues the light sequence will use (here it is set to 30 to make the hues remain within the red, orange, and yellow range but if it were set to 255, the lights would rotate through a rainbow). Make sure the light sequence is within a "run in parallel" block to ensure that it will play simultaneously with the sound sequence.

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.

For the second light animation, duplicate the first light animation's code. Change "touch A2" to "touch A3" (this is another touch sensor on the Circuit Playground Express). Set the pixels to blue and shift the numbers in the mathematical formula in order to have the hues remain within the blue and blue-purple range (see image 6). Go into Javascript and adjust the pause duration. In Javascript add the phrase "hue = Colors.Green" to make sure that the hue range remains in the blue range (see image 7).

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.