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 different 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.
image developed using Fritzing. For more circuit examples, see the Fritzing project page
click the image to enlarge
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:
Last revision 2015/08/11 by SM