Office Door Castle Knocker

We're always looking for more ways to make our office fun and strange. One of our engineers, Mike, recently rigged up the elevator to play the Tardis noise. I wanted to do something similar, but, specifically, in my office. I don't often work with my door closed, but the majority of time when someone comes into my office, they give the door the ceremonial announcement rap to indicate their presence. I decided to have a little fun with that.

Instead of the door making the standard boring door noise, I wanted my door to sound like the castle door knockers from Young Frankenstein.

What knockers!

Soitenly. You take the blonde, I'll take the one in the turban.

In order to do this, I would need a few things:

  • something to detect the knock and
  • something to play the sound.

For the knock detection, I chose our Large Piezo Vibration Sensor.

This sensor is perfect because it's cheap and only requires a resistor to be used with an Arduino ADC. The sensor outputs a small AC voltage when the film moves back and forth. All I have to do to use the element is solder it in parallel with a 1M Ohm resistor, connect one lead to an ADC pin and the other lead to ground. I simply soldered a resistor in between the leads on the device, and then I soldered on wires to connect to the Arduino later.

The second major piece of the project is something to play sound. In order to play the sound, I needed to get the sound. Luckily, I was able to find an mp3 clip of the scene from Young Frankenstein here.

The mp3 was a recording of the entire scene, so I had to cut out just the sound of the door knocker using a very useful program called Audacity. It's my go-to program when I have to do any simple editing of sound files, and it's free. With Audacity, I opened the mp3, cut out everything but the knock sound and amplified the waveform as high as I could before it started clipping so that it would be as loud as possible.

Next, I exported the file as an mp3 and saved it as "track001.mp3." The reason for this particular file name will be revealed later. After that, I loaded the mp3 onto a microSD card to later be used with the MP3 Player Shield.

The MP3 Player Shield is designed to play mp3s triggered by an Arduino. It has a microSD socket to hold the mp3 files and a VS1053 audio codec to process the raw mp3s and output them as audio through a 3.5mm audio jack. The product page has an example sketch that simply plays the mp3 files on the microSD card one after the other in an endless loop. Since I want to trigger the sound only when a knock is detected, I had to make some modifications to the code.

Here is the final Arduino sketch for this tutorial if you're playing along at home.

First, I need a function that checks the Analog 0 line and returns whether or not a knock is detected. I added the readPads() function at the bottom of the existing code:

int readPads(void)
  if(analogRead(0) > SENSITIVITY) { return TRUE; }
  return FALSE;

The constant "SENSITIVITY" is defined at the top of the sketch as 3. Since the piezo sensor is pulled to ground, it will report a zero voltage until it is agitated. Setting the SENSITIVITY constant to 3 means that any time a value greater than 3 is detected, the function returns true. This makes the sensor very sensitive, but since it has to detect a knock through a thick door, I set it low just in case.

Next, I need to modify the code in the loop() function to play track001.mp3 only when a knock is detected. Since the code is already written to play multiple tracks, I had to remove more code than I had to add. The final loop function looks like this:

void loop(){
    int pad_pressed = FALSE;
    pad_pressed = readPads(); // Check for a "knock"
    if(pad_pressed == TRUE)
        trackNumber = 1;
        sprintf(trackName, "track%03d.mp3", trackNumber); //Splice the new file number into this file name
        playMP3(trackName); //Go play trackXXX.mp3

This code first calls the readPads() function. If the function returns TRUE, it plays the first track. If the function returns FALSE, it loops and checks again. Very simple. I attached the shield to my Arduino, soldered on the piezo sensor, and sure enough, when I tap the sensor, it plays the sound.

Now to attach it to the door. For this, I special-ordered a precisely-machined custom attachment device from my local supply shop:

Just kidding.

I powered the Arduino with 4 AA batteries in a battery holder with a barrel jack. I then used a 3.5mm audio cable extension to connect the MP3 Player Shield to my computer speakers. I attached the piezo sensor to the back side of the door, right about the height where someone would knock. The whole rig looks like this:

The final effect was pretty impressive:

Now when someone knocks on my door it sounds like they're using a giant door knocker. This project is just one example of how to integrate sound into objects using our MP3 shield and a piezo sensor. I've used this set up with drum sounds and multiple piezo sensors to make electronic drums and other percussion instruments. One could use it to turn just about anything into an instrument! Be sure to check out our force/flex/piezo sensors for more ideas.

Comments 15 comments

  • mikep / about 12 years ago / 2

    So rad. I suppose the sensor could be wired directly to an XBee and the arduino/mp3shield could live by the stereo.

  • Seriously, Chris, this is absolutely glorious! Looking forward to building one (or several) of these. Thank you so much for sharing. And of course, there can be only one statement that follows anyone knocking on the door now...

  • Member #266467 / about 12 years ago / 1

    This program is not working for me, it compiles and loads. I checked the sensor wiring, etc.. The mp3 keeps playing over and over. Can someone help?

  • Member #304531 / about 12 years ago * / 1

    This is very nice and hilarious idea to welcome the guest. People even can try this on different occasions like Halloween, St Patrick's day or April fool day. But what I am saying is many times people can knock at other place. But still a very good idea for office or home door for some special humorous people. I recall one of the Irish sayings - You've got to do your own growing, no matter how tall your grandfather was. Means that does not matters how properly you taught us but the thing matter is what the learner would do.

  • awesome!

  • Cerebral_Knievel1 / about 12 years ago / 1

    Of course, I'm assuming it would be very easy to insert a bit of code to run some lighting effects as well? and change the knock sensor to IR motion detector?

  • I just threw this together and have a strange problem. It works perfectly except that every now and again the wiring seems to react like a capacitive touch sensor. Once it starts working this way I can activate the sound by getting within 2 inches of the wiring or sensor without touching anything. Any idea why this occurs? It even does it through the door without out touching it!?!

  • Blacklab1 / about 12 years ago / 1

    Now all you need is the squeek for the door when you open it or close it. I bet that can be done too.

  • MoriFi / about 12 years ago / 1

    I just got a nice (idea for an) addition to this. Add the noises of a old door handle turning,and the door creaking open.

  • madsci1016 / about 12 years ago * / 1

    I just finished writing an Arduino library that would make it easier to implement this project:

    Check it out.

  • khearn / about 12 years ago / 1

    Could you use Sparkfun's large surface transducer (sku: COM-10975) directly attached to the door to make the sound actually come from the door itself? That would be even cooler than this already is.

    Edit: You'd have to ignore the piezo sensor while the sound was playing, though, cause it would probably be going nuts.

    • I thought of doing that, but even our large surface transducers wouldn't produce the volume that I wanted. Even with several of them at high amplification, I would still have to rely on the resonance of the door itself, which isn't very loud.

      • Kevin Vermeer / about 12 years ago / 1

        That looks like a pretty solid door, from the heavy-duty handle and how little it moves when you knock on it. Is this correct?

        I'd expect a standard residential hollow-core door to be pretty loud, especially if you cut back the veneer from the inside and adhered the surface transducer to the outside layer.

        • Cerebral_Knievel1 / about 12 years ago / 1

          Years ago in my Drunk rock days I would use Surface transducer mikes mounted to hollow "interior" doors to record drum kits. worked very well for the low ends.

          Then of course.. there was the time My assistant and I convinced the night manager at the pub that the brewery was Haunted. Then took a old Peizo transducer tweeter horn, removed the horn and Duct taped the unit to an Iron pipe running through the brewery. I had then made a 5 hour long MP3 file of random haunted house noises and hooked the tweeter to an amp, and the amp to a MP3 player. and hit "play" before I left for the night. the already spooked out pub night manager had to go down stairs to the brewery to do the nights books...

          it was an overall good effect and I'm very sorry that all that security camera video footage is lost.