Trybotics Logo

Happy Birthday-Buzzer and Button

DESCRIPTION

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

Description:

Description:

Description:

Description:

Description:

Description:

Description:

Description:

Description:

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.

Description:

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.

Description:


YOU MIGHT ALSO LIKE