Happy Birthday-Buzzer and Button

Intro: Happy Birthday-Buzzer and Button

This project uses the Arduino Uno, a buzzer, and a button to play the song Happy Birthday! When the button is pushed the buzzer plays the entire song of Happy Birthday. I see the connection to the musical birthday cards that my children love so much.

I chose to create this project because when I completed my first project using a buzzer it did not include a button and played a very simple pattern. I had used buttons to light LEDs in the past so I decided to add a button to the buzzer and also create the song Happy Birthday as a surprise for my son's 5th birthday! He loved it and played over and over! As kids always do he loved pushing the button. The hardest part of this project was creating from scratch the code for the song happy birthday but it was fun to see how coding can connect to other subjects such as writing music.

Skill Level: Beginner

Inspiration credited to:

Kilic, M. (2016, November 24). Button buzzer melody. Retrieved from http://mertarduinotutorial.blogspot.com.tr/2016/11/buzzer-button-melody.html

Materials

  • Arduino Uno Micro-Controller
  • Breadboard
  • Piezo buzzer
  • button
  • 10K resistor
  • 5 male-male Jumper Wires
  • USB connector cable

Step 1: Attach the Button to the Breadboard

Step 2: Connect a 10K Resistor to One of the Button's Legs.

Step 3: Connect the Resistor's Other Leg to Ground (GND) With a Wire

Step 4: Connect the Button's Other Leg With a Wire to the +5V

Step 5: Connect the Button's Top Right Leg With a Wire to the Digital Pin 12

Step 6: Attach the Buzzer to the Board. Take Note of the Labels for the Positive (+) and Negative (-) Sides of the Buzzer.

Step 7: Use a Wire to Connect the Negative (-) Leg of the Buzzer to Ground (GND)

Step 8: Use a Wire to Connect the Positive (+) Leg of the Buzzer to Pin 8

Step 9: Coding Your Arduino

Now we are ready to get the code for your project. Go the following link and copy the code into your Arduino editor.

Happy Birthday Code

Code to take note of:

  • Create a second tab for the pitch catalog code and name it: pitches.h
    • Paste the code from the pitches catalog into your new pitches.h tab
    • Lines 4-9 in the code are the notes for the song happy birthday. The notes come from the pitches.h tab
    • Line 15 contains the note durations that correspond to the notes in lines 4-9
  • Line 42 is where you regulate the speed of the Melody. If you want to speed up or slow down the melody change this number accordingly.
  • Line 34 is where you set how many notes will play in the song. So if you write a new melody you may need to adjust the number 28 to match the number of notes in your new melody.

Step 10: Congratulations You Are Done! Now Push the Button and Listen to the Sweet Music of Happy Birthday!

Now that you have played Happy Birthday try your musical skills and code a new song of your very own using the pitches.h tab as a catalog of code for the different notes.

Share

    Recommendations

    • Fix It! Contest

      Fix It! Contest
    • Audio Contest 2018

      Audio Contest 2018
    • Furniture Contest 2018

      Furniture Contest 2018

    Discussions

    0
    None
    DIY Hacks and How Tos

    4 months ago

    This would be great to integrate into a present so that it would automatically play the song.