User Manual

{
OrangutanBuzzer::playFromProgramSpace(melody);
}
#include <avr/pgmspace.h>
const char melody[] PROGMEM = "!L16 V8 cdefgab>cbagfedc";
void someFunction()
{
play_from_program_space(melody);
}
static void OrangutanBuzzer::playMode(unsigned char mode)
void play_mode(char mode)
This method lets you determine whether the notes of the play() sequence are played automatically in the
background or are driven by the play_check() method. If mode is PLAY_AUTOMATIC, the sequence will
play automatically in the background, driven by the Timer 1 overflow interrupt. The interrupt will take
a considerable amount of time to execute when it starts the next note in the sequence playing, so it is
recommended that you do not use automatic-play if you cannot tolerate being interrupted for more than a few
microseconds. If mode is PLAY_CHECK, you can control when the next note in the sequence is played by
calling the play_check() method at acceptable points in your main loop. If your main loop has substantial
delays, it is recommended that you use automatic-play mode rather than play-check mode. Note that the play
mode can be changed while the sequence is being played. The mode is set to PLAY_AUTOMATIC by default.
static unsigned char OrangutanBuzzer::playCheck()
unsigned char play_check()
This method only needs to be called if you are in PLAY_CHECK mode. It checks to see whether it is time to
start another note in the sequence initiated by play(), and starts it if so. If it is not yet time to start the next note,
this method returns without doing anything. Call this as often as possible in your main loop to avoid delays
between notes in the sequence. This method returns 0 (false) if the melody to be played is complete, otherwise
it returns 1 (true).
static unsigned char OrangutanBuzzer::isPlaying()
unsigned char is_playing()
This method returns 1 (true) if the buzzer is currently playing a note/frequency or if it is still playing a
sequence started by play(). Otherwise, it returns 0 (false). You can poll this method to determine when it’s
time to play the next note in a sequence, or you can use it as the argument to a delay loop to wait while the
buzzer is busy.
static void OrangutanBuzzer::stopPlaying()
void stop_playing()
This method will immediately silence the buzzer and terminate any note/frequency/melody that is currently
playing.
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
3. Orangutan Buzzer: Beeps and Music Page 17 of 65