User Manual
3. Orangutan Buzzer: Beeps and Music
The OrangutanBuzzer class and the C functions in this section allow various sounds to be played on the buzzer
of the Orangutan LV, SV, SVP, X2, and 3pi robot, from simple beeps to complex tunes. The buzzer is controlled
using one of the Timer 1 PWM outputs, so it will conflict with any other uses of Timer 1. Note durations
are timed using a Timer 1 overflow interrupt (TIMER1_OVF), which will briefly interrupt execution of your
main program at the frequency of the sound being played. In most cases, the interrupt-handling routine is very
short (several microseconds). However, when playing a sequence of notes in PLAY_AUTOMATIC mode (the
default mode) with the play() command, this interrupt takes much longer than normal (perhaps several hundred
microseconds) every time it starts a new note. It is important to take this into account when writing timing-
critical code.
Note that the Orangutan X2 uses its auxiliary microcontroller to control the buzzer. The firmware on this
microcontroller duplicates the play_note() and play_frequency() functionality of this library, so it is possible to
play music on the Orangutan X2 without using Timer 1 (see the Section 15 for Orangutan X2 functions). The
OrangutanBuzzer library functions call the appropriate functions in the OrangutanX2 library, so they produce
the same results on the X2 as they do on the other Orangutans, and they use Timer 1 to achieve the proper note
durations.
This library can be used with the Baby Orangutan if one pin of an external buzzer [https://www.pololu.com/product/
1261] is connected to pin PB2 and the other pin is connected to ground.
For a higher level overview of this library and example programs that show how this library can be used, please
see Section 3.b of the Pololu AVR C/C++ Library User’s Guide [https://www.pololu.com/docs/0J20].
Note: The OrangutanServos and OrangutanBuzzer libraries both use Timer 1, so they cannot
be used together simultaneously. It is possible to alternate use of OrangutanBuzzer and
OrangutanServos routines, however. The servos-and-buzzer example program shows how this
can be done and also provides functions for playing notes on the buzzer without using Timer 1 or
the OrangutanBuzzer functions.
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
3. Orangutan Buzzer: Beeps and Music Page 13 of 65