DIY : Musical Death Star – Ruben Lopez – Medium
In my last tutorial, I showed you how to build a simple musical birthday cake. This tutorial will expand on that simple schematic by adding a larger speaker with an audio amplifier and a rechargeable battery in a fully enclosed Death Star! The Death Star will start playing the Imperial March theme when placed near a magnet. See it in action here.
Bill of Materials
- 3D printed Death Star with stand (I used this model by embeddedjunkie)
- TP4056 lithium battery charger module
- LM386 micro amplifier module or any mono amplifier board
- 8 ohm 0.5 W speaker
- Reed switch
- 8-Pin DIP socket
- Perf board
- Micro USB breakout board
- 3.7 volt lithium polymer battery (I used a small 30 mAh battery)
Programming the ATtiny85
Flash the ATtiny85 with the Imperial Death March hex file. See Make a Musical Birthday Cake for more information on how to program an ATtiny microcontroller.
Imperial Death March theme source code on GitHub.
I think it is easier to show a Fritzing breadboard view for this project since there are several module boards involved.
Step 1: Add micro USB connector
Cut one of the slots on the Death Star to make a hole for the micro USB breakout board.
You will need to attach the micro USB breakout board using hot glue or a 3D pen.
I used a 3D printing pen to build a harness around the micro USB breakout board. The plastic melted together with the Death Star and created a strong bond.
Step 2: Add reed switch
Carefully bend the leads on the reed switch and solder wires to each lead. The glass enclosure is fragile and is easy to break so try not to bend the leads too close to the enclosure. Use your multimeter to test the switch after you bend the leads.
Attach the reed switch to the bottom of the Death Star with hot glue. This switch will turn the music on when a magnet is placed nearby.
Step 3: Add battery and charger
You will need to swap a resistor on the TP4056 module to reduce the charging current for a smaller battery. The charging current is set to 1 Amp, which is too high for the 30 mAh battery I am using. Take a look at the datasheet to see which value you need to use for your battery.
I changed the resistor to a 10K resistor for the lowest charging current supported. Unfortunately, I did not have a 10K SMD resistor, so I had to improvise.
Once you are done with the modification, you should test the module to make sure it is producing the correct charging current. Another thing to note is that we will not use the mini USB connector but connect the board to the micro USB breakout board instead.
Connect the micro USB breakout board VCC and Ground pins to the TP4056 module IN + and IN — pins.
Connect the battery to the TP4056 module BAT + and BAT — pins. Leave some space to add an additional wire to each pin.
Connect one of the wires from the reed switch to the TP4056 module BAT + pin.
Add one wire to the TP4056 module BAT — pin.
Test this by connecting a USB cable, the red LED on the TP4056 should turn on and start charging the battery. You might want to wait a couple of hours to fully charge the battery. The green LED will turn on once the battery is full.
Step 4: Add the ATtiny85
Solder the 8-pin DIP socket to the perf board.
Connect PIN 8 (VCC) to the free wire on the reed switch.
Connect the BAT — wire from the TP4056 module to PIN 4 (GND).
Add a wire to PIN 5. This will be the audio signal wire.
Add one additional wire to VCC (PIN 8) and two to GND (PIN 4).
Insert the ATtiny85 microcontroller to the DIP socket. This should already be programmed with the Imperial March tune.
Test this step by connecting a speaker to PIN 5 and GND and moving a magnet near the reed switch. You should be able to hear the Imperial March tune. Make sure the battery has enough charge and double check the connections if you don’t hear the tune.
Step 5: Add audio amplifier module
This step will vary depending on the type of mono amplifier module you choose. There are several on eBay. I used an LM386 micro amplifier module for this project.
The connections for any of the mono amplifiers should be very similar. Connect the module to power using the VCC and GND wires from Step 4 above. Then add the audio signal using the wire from PIN 5 to the modules IN + pin and the remaining GND wire to the IN — pin.
Finally, add wires for the speaker output. Take note of the polarity. I marked them as speaker + and speaker — in the picture below.
Step 6: Add speaker and test
Connect the speaker, remember to match the polarity.
Now move the magnet close to the reed switch, and you should hear the Imperial March tune. If you don’t hear anything go back and double check all the solder points, check to make sure the battery is charged, and make sure the volume level is not set to 0 if your amplifier module has a volume control.
Here is a picture of everything wired together.
Step 7: Assemble the Death Star
Glue the 3D printed middle ring to the top portion of the Death Star.
Add the speaker to the top portion and secure it with hot glue.
Carefully stuff all the wires and modules into the bottom portion of the Death Star.
You should end up with something like this:
Glue the top and bottom portions of the Death Star together and place it on the stand.
Now enjoy your Musical Death Star. Start the Imperial March tune by moving the magnet close.
Ideas and Enhancements
Here are some ideas for improvements if you plan on building your own Death Star.
- Expose the TP4056 module status lights
- Replace the reed switch with a small button
- Program more Star Wars tunes into the ATtiny85