PROJECT: Play 3 Tones to a Speaker
Step 1 - Build the Project
Writing three tones to a speaker is something the Arduino software is very good at- there is even a built-in tone command. This command works by entering the pin that you want to send the tone to, then the frequency of the tone, measured in hertz.
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
A tone will continue to play forever if you don’t use the command noTone to stop it. All of the code here exists in the setup() section, so it will happen only one time. After setting the speaker pin as an output, it’s ready to accept current to create a tone.
Next is defining the hertz of the tones you want to create. You can look up the frequencies of many notes on the internet and try to play songs with hertz. Here we play a 250 hertz tone for 1 second, then a 450 hertz tone, then an 850 hertz tone for one second and stop all of the tones.