Step 4 - Watch the Video Walkthrough

Code Walkthrough Text

This program uses two new functions tone and noTone() to play some tones in order. However, the tones only play one time each.

A tone will continue to play forever if you don’t write some code to stop it. Many computer commands work that way- you have to tell the code exactly when to start and exactly when to stop. tone can be stopped either by writing a new tone to the speaker (overwriting the tone) or with the noTone() function. 

The tone function needs two arguments: pin number and tone (in hertz). The noTone() function only needs one argument: pin number. By combining the tone function with delays and noTone(), you can create songs, jingles, and sound effects.

You'll notice that the tones only play through one time in this program. That's because of where the code is located. The code inside the void setup(), which spans from the opening { after setup to the closing } on line 19, only runs one time, when the Maker Board is powered. This is a useful area for setting up pins with pinMode or signaling the beginning of a program with a tone or light.