User Manual
• ‘<’ plays the next note one octave lower
• ‘+’ or ‘#’ after a note raises any note one half-step
• ‘-’ after a note lowers any note one half-step
• ‘.’ after a note “dots” it, increasing the length by 50%. Each additional dot adds half as much as the
previous dot, so that “A..” is 1.75 times the length of “A”.
• ‘O’ followed by a number sets the octave (default: O4).
• ‘T’ followed by a number sets the tempo in beats/min (default: T120).
• ‘L’ followed by a number sets the default note duration to the type specified by the number: 4 for
quarter notes, 8 for eighth notes, 16 for sixteenth notes, etc. (default: L4).
• ‘V’ followed by a number from 0-15 sets the music volume (default: V15).
• ‘MS’ sets all subsequent notes to play play staccato – each note is played for 1/2 of its allotted time,
followed by an equal period of silence.
• ‘ML’ sets all subsequent notes to play legato – each note is played for full length. This is the default
setting.
• ‘!’ resets the octave, tempo, duration, volume, and staccato setting to their default values. These
settings persist from one play() to the next, which allows you to more conveniently break up your music
into reusable sections.
• 1-2000: when immediately following a note, a number determines the duration of the note. For
example, C16 specifies C played as a sixteenth note (1/16th the length of a whole note).
This function plays the string of notes in the background while your program continues to execute. If you call
another buzzer function while the melody is playing, the new function call will overwrite the previous and
take control of the buzzer. If you want to string melodies together, you should put an appropriate delay after
you start a melody playing. You can use the is_playing() function to figure out when the buzzer is through
playing the melody.
Examples:
// play a C major scale up and back down:
OrangutanBuzzer::play("!L16 V8 cdefgab>cbagfedc");
while (OrangutanBuzzer::isPlaying());
// the first few measures of Bach's fugue in D-minor
OrangutanBuzzer::play("!T240 L8 a gafaeada c+adaeafa >aa>bac#ada c#adaeaf4");
// play a C major scale up and back down:
play("!L16 V8 cdefgab>cbagfedc");
while (is_playing());
// the first few measures of Bach's fugue in D-minor
play("!T240 L8 a gafaeada c+adaeafa >aa>bac#ada c#adaeaf4");
static void playFromProgramSpace(const char* sequence)
void play_from_program_space(const char* sequence)
A version of play() that takes a pointer to program space instead of RAM. This is desirable since RAM is
limited and the string must be stored in program space anyway.
Example:
#include <avr/pgmspace.h>
const char melody[] PROGMEM = "!L16 V8 cdefgab>cbagfedc";
void someFunction()
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
3. Orangutan Buzzer: Beeps and Music Page 16 of 65