Skip to content

Make a Musical Birthday Cake

In this tutorial, I will show you how to build a musical birthday cake. The project uses a 3D printed cake to house a simple circuit with an ATtiny13A microcontroller.  It uses a reed switch that triggers the Happy Birthday tune whenever the cake is placed on top of a magnet.

Cake

Bill of Materials

  • 3D printed cake (The one I used)
  • ATtiny13A
  • Reed switch
  • Piezo buzzer
  • 8-Pin DIP socket
  • Magnet
  • Perf board
  • 2 x LR41 batteries
  • Electrical tape

CakeParts

You can find most of these materials on eBay or Amazon.  You’ll have to 3D print the cake yourself or get creative and make one out of cardboard.

Programming the ATtiny13A

You will need to program the ATtiny13A with the code that plays the Happy Birthday tune. See this tutorial from SparkFun if you need help programming an AVR chip.

For this you will need:

  • Programmer such as the AVRISP mk.II or USBasp
  • Atmel Studio 7
  • Happy Birthday Tune source code

You don’t have to use Atmel Studio 7, you can use avr-gcc with AVRDUDE from the command line if you know what you are doing.

Use Atmel Studio or avr-gcc to compile the Happy Birthday Tune source code to produce a HEX file.  Use the programmer to flash the ATtiny13A with the HEX file.

Simple Circuit Schematic

HappyBirthdaySchematic

This circuit uses pin 5 to drive the speaker.  It is very simple to build. You will need to place the reed switch on pin 8.

Building

Follow these steps:

  1. Cut the perf board into a small circle that will fit inside the cake. See the picture above.
  2. Cut two wires for the battery connections.
  3. Place the 8-pin DIP socket and the piezo speaker from the top of the perf board and solder per the schematic.CakeBoard
  4. Place the reed switch from the bottom of the perfboard and connect one end to pin 8 (VCC) and the other end to the positive wire.CakeSoldering
  5. Put the ATtiny13A chip into the 8-pin DIP socket. Be careful not to bend the leads.
  6. Tape the 2 LR41 batteries together and attach the positive and negative wires.
  7. Put everything inside of the cake.CakeInternal
  8. Assemble the cake then put it on top of the magnet to start playing the Happy Birthday tune.

Final Product

Cake2

You can modify this circuit and source code to play just about anything.  The ATtiny13A has limited memory but it can be swapped out for an ATtiny85 for longer tunes.  I used a modified version for the Death Star the plays the Imperial Death March that I built for my son.

1 thought on “Make a Musical Birthday Cake”

  1. Pingback: Build a Custom Toy Traffic Light | Ruben's Thoughts

Leave a Reply

Your email address will not be published.