Skip to content

Ard Tone Multi

DodaTech 1 min read

In this tutorial, you'll learn about Arduino tone() Conflict on Multiple Pins. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Trying to play different tones on multiple pins simultaneously fails.

Quick Fix

Wrong

tone(9, 440);
tone(10, 880);  // Second tone fails silently
Only pin 9 produces sound. Pin 10 is silent.
// Play notes sequentially on one pin
int buzzer = 9;
int melody[] = {262, 294, 330, 349};  // C D E F
int noteDurations[] = {200, 200, 200, 200};

void setup() {
  for (int i = 0; i < 4; i++) {
    tone(buzzer, melody[i], noteDurations[i]);
    delay(noteDurations[i] + 50);
  }
}
Plays C-D-E-F sequentially on the buzzer.

Prevention

tone() uses one timer and can only output one frequency across all pins. For multi-note audio, play notes sequentially or use an external sound module (DFPlayer, MIDI shield). For simultaneous tones, use multiple boards or external tone generators.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### Can I use tone on multiple pins for the same frequency?

Yes. Calling tone(pin, freq) on different pins with the same frequency works. The same timer signal is routed to multiple pins.

What is the alternative for multi-tone?

Use a DFPlayer Mini for MP3 playback, or a MIDI module for polyphonic sound. These handle multiple voices in hardware.

Does tone() work during delay()?

Yes. tone() generates a PWM waveform in hardware that continues during delay(). The sound does not pause.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro