Step 1: Check the materials you need.
I used an Arduino Pro Mini 3.3V. You also need USB-Serial tether to program it.
2. A battery box
I used a AA x 4 battery box with power line wires.
I used a mini breadboard by Sparkfun.
4. ECM (Electet Microphone) Module
I used an ECM module by Sparkfun.
5. RC Servo motor
I used a mini servo motor EK2-0508 by E-Sky.
6. Jumper wires
7. An Aluminum Electrolytic Capacitor
I used a 100uF capacitor.
8. A knocker hammer parts
I used a small wooden ball toy.
9. A flexible metal wire
It is for connecting the servo horn and the knocker hammer.
A steel wire 2mm in diameter will be suitable.
10. Double-stick tape
It is for making the parts bond, and for mounting the device on the door.
Step 2: Make the knocker hammer.
Make the wire to be in hole and bend it to fix on the servo horn.
Bond the ball (or whatever you choose for hammer) to the wire.
Drill the hammer if you need.
Step 3: Mount the breadboard and the servo on the battery box.
And make the RC servo fix on the battery box to move the servo horn can move.
Step 4: Wire the circuit on the bread board.
Analog input is for the microphone, and Digital Output(PWM) for the servo motor.
The mic module needs the power at Vcc(3.3V) from arduino's Vcc pin.
The servo motor requires 5 to 6V to be driven, so you connect the battery power to it.
What is the capacitor into VCC and GND? Because I have been suffered from the noise of microphone. The combination of the ECM module by Sparkfun and Arduino seems to be unstable. For instance, when I wrote serial communication code to monitor A/D value, it cause enormous noise and the A/D value keeps high. So the capacitor is to ease my mind.
Step 5: Download the program.
Program code for arduino:
It recognizes the knocking sound and counts them, and move the servo to mimic the knocks.
Step 6: Check and adjust the hammer position.
Bend the wire of hammer to make knock the door face properly.
Step 7: Finished!
Now put it on the door face with double stick tapes.
It may help the prank to put a sign "Knock please." on the other side of door.