Ba Dum Tish Machine

You know, the sound the drummer makes when someone tells a bad joke?  It’s hack week at work, and my co-workers love to tell bad puns, so I’m making a little Ba-Dum-Tish machine to activate when they tell a bad pun.

I have have a few options for how to play the sound, but I wanted to experiment with the “simplest”  which for me means, a single arduino that is able to just play the sound.  I have some backups which include a board designed to play wav files when triggered, but if all goes to plan, i’ll be able to just use a stock arduino to do this.

Playing the audio

to play the audio, i’m using the PCM audio library.  initially I tried to just use delay statements but that just ended up in static coming out of the speaker (I might look into this again later, as it could have just been me using the incorrect timing for 8k audio.)

Converting the audio

Converting the audio is pretty easy.  Once you get some 8k mono audio (about 2 seconds)  you take the wave file which is a bunch of points in time at different values, and then convert those values to the range the arduino understands which is between 0 and 255.  So you get the min and max values from the wav file, and then use a translate function to translate all those points into the range of 0 to 255.

Once you get all those values, you create an array and store it in the Arduino’s program memory (variable memory isn’t big enough for this.)

The Electronics

The PCM library uses pin 11, so you hook the leads of your speaker to pin 11, and the other to the ground on the Arduino.

The Drum Case

To create the case, I laser cut the top and bottom, hooked it together with dowel rods, painted it, and then put some craft foam around the outside so it looked vaguely drum shaped.

The final drum:


Pushing the top, presses the button down and activates the audio to play.

All the code and files can be found on Github.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s