Capacitive Touch Rhythm Game!
I made a capacitive touch rhythm game (code included)! This game includes RGBs that light up to indicate which buttons to press, as well as editable code to turn your favorite songs into fun games!
NOTE: You will need access to a laser-cutter and a soldering-kit along with the listed supplies!
Supplies
- 1/8 inch Birch Wood (not shown)
- Wood Glue (not shown)
- 1/8 inch Clear Acrylic (not shown)
- Wago 5-Connector Lever (2x)
- Bunch of Different Color Wires (14 or 12 AWG)
- Adafruit Flora Smart RGBs (4x)
- Wirecutter/Wirestripper
- Electrical Tape
- Soldering Kit (not shown)
- Foam Board
- Audio Cable
- Multimeter
- Capacitive Touch Tape
- Duck Tape
- Hot Glue Gun
- Adafruit CircuitPlayground Bluefruit (not shown)
- Screws + Washers (should fit through the holes of the CPB with extra space)
Cut Out Box Parts + Box Top
Using the Adobe Illustrator (AI) "rhythm_box" file listed below, laser-cut the box design out of 1/8 inch birch wood.
Use the "rhythm_box_top" file to laser-cut the top-section out of the 1/8 inch clear acrylic. The laser-cutter should also engrave the top to help with light diffusion (included in the file design)!
Assemble Box
Using wood glue (the brand I used is in the picture), glue the top and all the sides. I would recommend these three sides together first, then glue the other sides EXCEPT FOR THE BOTTOM!
NOTE: the holes in the sides should both further away from the cross hole!
Wiring Connectors
Cut four wire the same length shown in the picture, and snap them into the connector. Then, cut one wire that is much longer. Snap this one into the OUT part of the connector. Be sure to strip all the ends of the wire! Repeat again with a different color of wire. These will be our POWER and GROUND connections.
Tape these two parts together with electrical tape as shown in the picture.
Wiring RGBs
Cut out 3 more wires of a different color, and strip the ends. Make sure they are long enough to allow the LEDs to rest under each part of the cross (look at future pictures for guidance!). Cut out one much longer wire. This will be our connection to the CPB!
ALSO make sure the arrows follow one another STARTING AT THE LONG WIRE (long wire -> arrow facing away). All the "+"s should be facing outward and the "-"s on the inside.
Here is the tough part: You will need to solder all these connections 😅. You could just twist the wires, but there is no guarantee that the connections will be secure. Look at my picture for guidance!
Tape + More Wiring!
Place four strips of conductive tape on each side of the cross. Cut out four long wires, ideally of four different colors, I only had two! Strip the ends, curl them, then solder to the tape!
Cross Wires Go In!
Cut out a piece of foam that can fit inside the box. Make sure it is thin enough that light can shine through (test using the flashlight on your phone). Then cut a hole in the center of it. Thread the wires from the cross through that hole.
RGB Wires Go In!
Next, put in the soldered RGBs. Make sure they line up with the center points of the cross! Then duck tape the wires in as well as the foam to the box to make sure it is secure!
NOTE: from the gap we left with the WHITE wires connecting the RGBS, there should be room for the cross wires to snake through!
NOTE 2: the RGB with the longest wire connected to it will be the UP LIGHT!
Glue the Top!
Hot glue the top to the box! Apply the glue to the outermost edges primarily, as the cross may be laying slightly above the center parts.
NOTE: the cross is larger than the hole to prevent it from being pushed through!
Wire to the CPB!
Here is the other difficult part 😅. We need to make all the connections to the CPB! I used screws, as I wanted to be able to take it apart if I needed to work with the CPB again, but you are also free to solder! ALSO for the audio cable, be sure to strip the ends of the connection!
Here is a list of all the connections:
RGB DATA: A3
RGB POWER: VOUT
RGB GROUND: GND (look at picture!)
UP-BUTTON WIRE: A4
RIGHT-BUTTON WIRE: A5
DOWN_BUTTON WIRE: A6
LEFT_BUTTON WIRE: TX
AUDIO RED: AUDIO
AUDIO GND: GND (look at picture!)
FINISH BOX!
Thread the audio cable out one hole, and the connection cable for the CPB out the other. Then close the box with the remaining wood piece. I would not glue that last part shut, just in case anything got messed up, or you want to see the inside in the future!
Now you are done! All that is left to do is load the following code and audio files on to your CPB! If everything is correct, pressing the UP-BUTTON should give a little introduction, LEFT and RIGHT should play songs + mappings that I have created, and DOWN should put you into TEST mode!
NOTE: if you are unfamiliar with CPBs, here is a good video for setting everything up!
CODING/FILES!
Rename the "rhythm_game" to "code" before putting it in the CPB, and put the mp3 files into a folder named "sounds". If you want to use your own sound files, be sure to follow these steps for audio conversion. Just be sure to change the parameters of the play_game()! To figure out when you want certain button presses to go, you can go into test-mode (make sure to change the TEST parameter to your song). This will output your presses/times to the screen to help with mapping!
When you know your mapping, you store it in a dictionary with a name of your choice where the keys and values are organized as such:
ex_mapping = {
timing : (directions, color, window * SEC),
...
}
where the timing is rounded to the tenth of a second, the directions are stored as a tuple of either one or two numbers (0 for up, 1 for right, 2 for down, 3 for left, two numbers for a multi input) and window is how long the player has to hit the note in seconds! Be sure to make the window time less than the time it takes to reach the next note, or else weird behavior may occur.
Have fun!