Sound & motion · Lesson
8 min read
Playing tones
tone() and noTone(), notes and rhythms with arrays.
What You Will Learn
- Play a frequency with tone()
- Store a melody in arrays
A passive piezo buzzer clicks each time the voltage changes. tone(pin, frequency) toggles the pin at that frequency, producing a note. Middle C is 262 Hz; A4 is 440 Hz.
Buzzer melodyarduino-uno
Note: Turn on sound in the Lab toolbar to hear it. Edit the notes array to write your own tune.
The Uno can play only one tone() at a time, and tone() interferes with PWM on pins 3 and 11.
Check Your Understanding
Test what you learned in this lesson