From Wiring

Jump to: navigation, search
This page is intended as a reference for core developers only, and the content is only changed after a consensus has been reached through discussion of any such changes. Please use the Discussion page to talk about any changes or issues you have with the current implementation.
Classification Tone Generator
Suggested location WTone.h
C++ required No
Timing constraints None
Version introduced 1.0 (0100)
Framework dependencies None
void tone(uint8_t _pin, unsigned int frequency, long duration)
Required? Yes
Issues None



The tone generates a tone of a determined frequency in hertz on a specific pin for a given duration.

Black Box Input

The pin number, the frequency (in hertz) and the duration (in milliseconds) are provided.

Black Box Output

No output.


None. Single signature only.


The max number of tones is limited by the number of timers on the board.

If a previous tone command is playing, and a new pin is specified, and tonePolyphony has been set to > 1, and there are available timers, a simultaneous tone will be played on the new pin.

The tone command uses timer resources to generate the tone accurately. Avoid using Timer0 because it is used for millis etc.

Use a negative number in duration for infinite duration.

Proposed Changes

For Wiring 1.1

According to Issue 9, pinWrite() will be defined as:

void pinWrite(pin_t pin, uint8_t value);

See Issue 9 for more details.

Personal tools