The SparkFun microphone board is intended to be
interfaced to a wide variety of electronics. While attaching
to an Arduino is one of its intended applications, the
connection requires a few additional components (shown in
Figure 5). The capacitor and 1N34A diode — the latter a
germanium type — form an unbiased DC clamp. As is
typical of an audio amplifier, the output of the breakout
board floats at a point midway between ground
and +V power. The clamp restores the voltage
in reference to ground (0V).

With the components shown and when
powered by 3. 3 volts (which I recommend), you
can expect converted analog-to-digital values
ranging from about 0 to 750 or 800 — the louder
the sound, the higher the numeric value.

Listing 3 shows a working sketch that polls
analog pin A0, and if it exceeds a preset threshold,
displays the value in the serial monitor window. The
threshold is purely for demonstration, so that only the
louder sound events trigger a reading in the serial monitor
(reduces clutter). Adjust the threshold variable to
experiment. In a full sketch, you’d
no doubt be interested in reacting
to sounds of varying loudness;
perhaps with an if or case
statement to perform different
actions, depending on the sound
level.

FIGURE 4. Electret
condenser microphone
amplifier breakout board
from SparkFun. It includes a
microphone and amplifier.

Photo courtesy SparkFun Electronics.

Reacting to
Different Sound
Frequencies

Loudness (volume) is just one
quality of sound your robot can
listen for. Another is the frequency
of the sound. Picture a piano keyboard, where the notes
produce different sound frequencies that your robot can
hear and follow.

You can combine a microphone and amplifier with a
tone decoder circuit that differentiates the frequency you
want from all other sound in the room. Fine idea in theory,
but tone decoder circuits are notoriously troublesome. A
better method is to use a specialty integrated circuit — an
audio equalizer IC that provides the relative amplitude of a
range of frequencies from 63 to 16,000 (16K) Hz.

The MSGEQ7 from Mixed Signal Integration, is an
inexpensive eight-bit chip that requires only a few common
external components, plus three connection wires to the
Arduino. A sample schematic — derived from the MSGEQ7
datasheet — is provided in Figure 6. The MSGEQ7 is
intended for use in building audio graphic equalizer displays
like the kind on your stereo or home theater system. It has
a single output pin that produces a voltage relative to the
loudness of the sound.

The chip is sensitive to several bands with each band
centered around the following frequencies: 63 Hz, 160 Hz,
400 Hz, 1 kHz, 2. 5 kHz, 6. 25 kHz, and 16 kHz. As a point

FIGURE 5. How to connect the microphone amplifier to the
Arduino. Be sure the ground connections between the amp
board and Arduino are shared.