Summary of SPlaying tones on Multiple outputs using the tone() function with Arduino
This example demonstrates using Arduino's tone() to play notes on multiple outputs by sequencing tones: turning off the timer for one pin before starting the next, since tone() uses a single hardware timer and can produce only one simultaneous note. The sketch sequences tones on pins 6, 7, and 8, each lasting the same as the following delay. Circuit uses three 8-ohm speakers with series 100-ohm resistors on a breadboard.
Parts used in the Multiple tone player:
- Arduino (Atmega-based board)
- (3) 8-ohm speakers
- (3) 100 ohm resistors
- Breadboard
- Hook up wire
This example shows how to use the tone() command to play different notes on multiple outputs.
The tone() command works by taking over one of the Atmega’s internal timers, setting it to the frequency you want, and using the timer to pulse an output pin. Since it’s only using one timer, you can only play one note at a time. You can, however, play notes on multiple pins sequentially. To do this, you need to turn the timer off for one pin before moving on to the next.
Thanks to Greg Borenstein for clarifying this.
Circuit

image developed using Fritzing. For more circuit examples, see the Fritzing project page
Schematic
Code
The sketch below plays a tone on each of the speakers in sequence, turning off the previous speaker first. Note that the duration of each tone is the same as the delay that follows it.
Here’s the main sketch:
Multiple tone playerPlays multiple tones on multiple pins in sequence
circuit:
* 3 8-ohm speaker on digital pins 6, 7, and 8
created 8 March 2010
by Tom Igoe
based on a snippet from Greg Borenstein
This example code is in the public domain.
Hardware Required
- (3) 8-ohm speakers
- (3) 100 ohm resistor
- breadboard
- hook up wire
For more detail: SPlaying tones on Multiple outputs using the tone() function with Arduino
- How does the tone() command play notes on multiple outputs?
It takes over one of the Atmega internal timers and pulses an output pin; to use multiple outputs you play notes sequentially and turn off the timer for one pin before the next. - Can tone() play more than one note at the same time?
No. Because tone() uses one hardware timer, you can only play one note at a time. - What is the recommended method to play on multiple pins?
Play notes sequentially on multiple pins, turning off the previous speaker before moving to the next. - Which Arduino pins are used in the example sketch?
Digital pins 6, 7, and 8 are used for the three speakers in the sketch. - How long does each tone play in the sketch?
The duration of each tone is the same as the delay that follows it in the sketch. - What components are listed as hardware required?
Three 8-ohm speakers, three 100 ohm resistors, a breadboard, and hook up wire. - Why must the timer be turned off for one pin before the next?
Because the tone() command uses a single timer to generate frequencies, it must be freed from the current pin before generating a tone on another pin.

