After it was assembled, I
mounted everything to a piece of
acrylic as mentioned, and labeled all
the connections (Figure 4). I don’t
want to have to figure out all these
connections next year!
You need to customize a cable
to trigger the KA2284. I used an old
audio cable, and tapped the right
channel to connect to the audio in
and ground pins (Figure 5).
Setting Up the
One of the quirks of these small MP3 players is
that they can’t read the directory of a memory card
and process it — you must organize the files on it in
order. Name them like this:
002 Scary rooms.mp3
003 Monsters ahead.mp3
Copy the files to the micro SD card; then, use a
utility to sort the FAT on the card. This way, the
commands from the Arduino will trigger the MP3 you
want. The utility I use is DriveSort.
Finally, load the software onto the Arduino. There
are two things you need to do to configure it for your
setup. First, figure out the sweep of the servo that
animates your skull’s jaw. If you scroll all the way to the
bottom of the code, the set_minmax function has
comments in it that tell you what values to change for the
motion you want. Ground pin 11 to get the servo to sweep
through these values for testing.
Look at how long each MP3 is and change the
Talk Time values at the top of the code to match.
The code is set up in a state machine, run by a timer.
When a state is triggered, the LED eyes are turned on, and
the command to play an MP3 is sent. The MP3 player —
acting as a co-processor — will then play the file and stop
on its own. The LED eyes are then turned off, based on
how long the TalkTime is for each state.
The big insight I had while doing this was to put all the
functions that monitor the audio and update the servos into
the main loop, and only jump to the states briefly to trigger
the MP3s. This lets the processor manage the servos until
the timer cuts it off. You can change the pause between
MP3s if you want; see the WaitTime variable at the top of
In earlier iterations of Bob, I set the code up to
randomly pick MP3s from a list until they were all used up,
and then clear the list and start over. That turns out to be
unnecessary — no one ever pays that much attention! They
see the skull is talking, listen to one or two things it says,
and move on. All I do now is run through the list, playing
each track in order, then start over at the top.
Let’s talk about the skull itself. Animating the jaw is
straightforward; the servo is mounted in the top of the
skull, and a wire or linkage goes down to the jaw. There
are several approaches you can take to building this,
depending on your budget and on how lifelike you want
SERVO 09.2017 47
Figure 5. Hack an old audio cable to trigger the KA2284 board.
Figure 4. Everything assembled and
Thanks to the following people who made this possible:
Mike "mikkojay" of HauntForum.com for the original
concept and code.
Jon "JonnyMac" McPhalen for years of answering
questions, awesome example code, and general