In this project we will use the piezo speaker to make music.
The following code does not use the buttons but is intended to show you how the piezo speaker works.
In your Arduino program enter in the following code:
Run the program and observe the results!
In the tone command you take in two parameters. The pin that supplies the power, followed by the frequency of the note. 440Hz is the note A.
Try the following code:
Before you run your program try and predict the outcome.
The noTone function requires one parameter; the pin that you are turning off.
The last code I want you to run is the following:
Create the code required to make a keyboard that will play a note when a button is pressed. There should be no sound coming from your circuit when the button is not pressed. You must be able to play the hit song “Mary had a little lamb”. You may need to look up the notes to the song, as well as their respective frequencies.
Once you are done submit your code and show me that you can play your keyboard.
Can play Mary had a little lamb:
Code submitted with comments explaining what the code does:
Total:
Extension:
Total:
80%
10%
90%
10%
100%
Extension
Research or play around with a third parameter for the tone function.
Rewrite your code so it uses that third parameter.
10%
FOR ALL OF THE ABOVE (AND FOR THE REST OF THE SEMESTER), YOU MUST LEAVE COMMENTS IN YOUR CODE EXPLAINING WHAT THE CODE DOES AND HOW IT WORKS! IF YOU DON'T YOU WILL LOSE MARKS!
When you are ready to submit your project, submit your code and pictures of your project to Google Classroom under Project 5 - Buzzer.
YOU MUST SHOW ME YOUR PROJECT BEFORE YOU SUBMIT IT!