Introduction: My Attempt at the Arduino Button Buzzer Melody

In this tutorial I will show you how a button can start a melody. During the school year, many of our lives are run by bells or tones that let us know when it's time to leave or time to go. Most of us rarely stop and think about how these different sounds can be made. I know when I think about creating different tones for bells in school, my mind always goes back to a scene from the movie Grease when the principal uses a mini xylophone to indicate the start and stop of her announcement. Bells and chimes surround us everywhere so I wanted to learn a bit more about them. In this tutorial I have created a system in which a sound is played when a button is pushed. The set-up is quite simple when using the tools needed so I highly recommend that beginners give it a try. The biggest challenge that I found was within the coding. As you'll see in Step 10, you will need to set-up the pitches.h in a separate tab before verifying your code. Once your system is built, press the button and see how many times others around you check their phone or look for an "old-school" video game nearby because they can't figure out where the noise is coming from!

Step 1: What You Need:

  • Arduino Uno
  • Breadboard
  • Piezo Buzzer
  • Button
  • Jumper Wires (5)
  • 10k resistor
  • USB Cable

Step 2: Place the Button on Your Breadboard

Step 3: Attach the 10k Resistor to the Leg of the Button

Step 4: Ground the Empty Leg of the Resistor With a Jumper Wire

Step 5: Connect the Button's Other Leg to the +5V

Step 6: Connect the Button's Top Leg to Digital 12

Step 7: Place the Piezo Buzzer on the Breadboard

Step 8: Connect the Buzzer's Short Leg (-) to Ground

Step 9: Connect the Buzzer's Long Leg (+) to Digital 8

Step 10: It's Time to Code!

Use the link below to copy the code.

Buzzer Button Melody Code

Don't forget the pitches.h library!

Here's a brief tutorial for the set-up (fast forward to 4:50 for pitches.h library only)

Code tutorial video

Step 11: Test It Out!


In-text: (, 2018) Your Bibliography: (2018). Arduino - Button Buzzer Melody. [online] Available at: [Accessed 14 May 2018].