Tone

Name
tone

This command is not currently supported by the Pinguino IDE

Description
Generates a square wave of the specified frequency (50% duty cycle) on a pin. A speaker or buzzer can be connected to the pin to play tones. Duration optional, if not specified the wave continues until a call to noTone. Use of the tone function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).

Board                   Min freq(Hz)     Max freq(Hz) ---            ---   -- Pinguino                           31              65535 Uno, Mega, Leonardo               31              65535 Most other AVR boards             31              65535 Zero                              41             275000 Gemma - Not implemented           -                 - Due  - Not implemented            -                 -

Syntax

 * tone(pin, frequency)
 * tone(pin, freq_hz, duration_ms)
 * tone(u8 pin, u8 frequency, u16 duration)


 * pin
 * IDE pin to generate the tone

Tone and sound use PWM, the device must be connected to a PWM pin. Pinguino x5(k)50   : 11, 12          (CCP1, CCP2) Pinguino 47J53     : 4, 5, 6, 7, 17  (CCP4, CCP5, CCP6, CCP7, CCP8) PIC32 Olimex Micro : 10, 11, 12, 13  (OC2, OC3, OC4, OC5) Other chips are unknown
 * frequency
 * frequency in hertz of the tone


 * duration
 * tone duration in milliseconds (optional)

if no duration is given, tone plays until noTone command

Example 1
tone(3, 1000);       // pin=3, tone=1000hz, continuous tone tone(3, 440, 250);   // pin=3, tone=440hz, duration 250ms (1/4sec) tone(3, 150, 250); tone(3, 1000); noTone(3);

Example 2

 * Twinkle Twinkle Little Star
 * C C G G A A G
 * F F E E D D C
 * G G F F E E D
 * G G F F E E D
 * C C G G A A G
 * F F E E D D C

Comments
Notes and frequency

9 octave reference chart using 440hz "A" note.