■ FIGURE 16. Proto shield with piezo buzzer.
■ FIGURE 17.
BUILD IT ON THE MINI
Over the past several Workshops,
we've seen how to build a DS1307-
based real time clock, so let's apply
that here and add a feature we
haven't seen yet: an audible alarm.
We will use the Fritzing piezo buzzer
part we created last month; let's test
TESTING THE PIEZO BUZZER
We will use a program that comes with the Arduino
IDE to do our preliminary tests. Open the toneMelody file
in the Arduino IDE File\Examples\Digital\toneMelody as
shown in Figure 18. This program should compile and
upload to the Arduino without any modifications, and the
piezo speaker should start playing the melody.
MAKING A LOUDER ALARM
So, that was kind of underwhelming. Yeah, it plays
tunes but not very loud. We see from Figure 19 that
the piezo buzzer volume is highly dependent on the
frequency of the tone, so that while we can hear the
music, most of the tones being played are fairly low
volume. Note that the peaks are around 2,000 Hz and
This is an intentional design tradeoff for the piezo
speaker since it wasn't really designed to play music, but
to output annoying alarm tones that will grab our
attention. Since that is exactly what we want, let's write a
program to beep it around those datasheet frequencies
■ FIGURE 18. Select toneMelody.
December 2012 59