Reference for Wiring version 0027+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.
Name |
tone() |
Examples |
void setup() {
// generates a 400Hz tone in output pin 0 with 200ms of duration
tone(0, 400, 200);
}
void loop() {
}
void setup() {
// generates a 400Hz tone in output pin 0 with infinite duration
tone(0, 400, -1);
}
void loop() {
} |
Description |
The tone() generates a tone of a determined frequency in hertz on a specific pin with a specified duration. The tone command uses timer2 to generate the tone accurately. Use a negative number in duration for infinite duration. |
Syntax |
tone(pin, frequency, duration) |
Parameters |
pin |
int the output pin number in which the tone will be generated. |
frequency |
int: the frequency for the pulse in Hertz |
duration |
int: the tone duration in milliseconds or a negative number for infinite duration |
|
Returns |
None |
Usage |
Application |
Related |
noTone()
|
Updated on September 16, 2010 10:41:31pm PDT