Main Content

Musical Treasure Box

Play a custom tune when your treasure box is opened to warn you someone may be trying to thieve your stuff!

I teach coding and electronics at high school and my students often ask how to implement a music box or an alarm that sounds when the light level changes. They usually manage to get something working to turn the tune on, but have thus far struggled to make the tune cease playing mid way through.

This project allows the maker to create their own tune to be played on a piezo buzzer with an analog input determining when the tune should stop. It can be used to create the musical treasure box but could also work well for a variety of other projects.

Assumed knowledge:

Able to build a circuit on a breadboard using a circuit diagram
Understand how to edit and upload an Arduino sketch
Know how to open the Serial Monitor and use the correct baud rate to track values
Have a basic understanding of how music notes and duration of each note and rest is used to create a tune”

Link to article