Week 5 Piezzo Buzzer Arduino Project

                     

       The Project

       This week I thought I'd take a break from using the Arduino LED light challenges and work with a         Piezzo Buzzer on the bread board.  The Piezzo Buzzer makes a small beep when voltage is sent to         it. By sending different voltages you can change the tone of the beep and even compose little songs         for the buzzer to play!

The Code

 



Photo of the Circuit



Diagram



Video




My Learning

I wanted to see what the Arduino program and breadboard could achieve outside of blinking LED light projects.  It was fun to see the program achieve sounds.  The circuit was very simple which allowed me to experiment and play around with the code to get different tones, instead of troubleshooting the circuit which is typically where I get bogged down.  I was a little daunted by the fact that my mini speaker Piezzo Buzzer looked slightly different than the buzzer on SIK Arduino kit (although I did get an official Arduino kit from their website) but the code worked just fine.  The buzzer also had a larger circumference which made me have to place it on the other side of the terminal strip of the breadboard and use two extra wires across the center groove to connect it to the 9th port and ground respectively.  Giving the tone a duration of milliseconds is important because without the duration the tone will continuously play and it won't sound like music.

 



 Final reflection 

I enjoyed playing and experimenting a lot with the code for this project.  The alphabet letter text characters are set to different frequencies which creates a different tone in the buzz.  For example note c has a frequency of 262 Hz and note d has a frequency of 294 Hz.  Once these frequency associations are set, you can compose different tones just by arranging the alphabet text characters in different arrangements in the code.  A space between the characters represents a rest with no tones.  The numbers 1 and 2 associated with beats represent quarter notes and half notes respectively.  There are 8 alphabet letter character notes with 8 frequencies.  I'm getting more confident using the i++ part of the code to use intervals of 1 in the duration.  The most complicated part of the code that I found a little confusing was "duration = beats[i] * tempo; if (notes [i] == ' ')"  I'm still having trouble understanding what the significance of the "*" symbol and the ' ' parenthesis is.  

Extensions

Since it's Christmas, I wanted to make the buzzer play "Jingle Bells."  I'm not musical enough to naturally know the notes so I had to look up the notes "eeeeeegcde fffffeeeeddedg" and the int duration "{1,1,2,1,1,2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,}" but the frequencies associated with the characters and the rest of the code was basically the same to play a the new song of "Jingle Bells." The electronic buzzer could be used for anything from toys to electronic greeting cards to megaphones.  Anytime an electronic tune might be appropriate such as a Christmas decoration this code and buzzer could be applied.

Comments

Popular posts from this blog

Makerspaces and Arduino Retrospective