Protect your secret hideout from intruders with a lock that will only open when it hears the secret knock.

This started out as a bit of a joke project, but turned out to be surprisingly accurate at judging knocks. If the precision is turned all the way up it can even detect people apart, even if they give the same knock! (Though this does trigger a lot of false negatives, which is no fun if you're in a hurry.)

It's also programmable. Press the programming button and knock a new knock and it will now only open with your new knock. By default the knock is "Shave and a Haircut" but you can program it with anything, up to 20 knocks long. Use your favorite song, Morse code, whatever.

Maybe a video will explain it better:

Important Notes:
(I hate to even have to say this, but since someone's going to say it, I'll say it first:)
1) This is for entertainment purposes only. Really. This decreases the security of your door by adding another way to unlock it, and it makes your unlock code known to anyone who can hear. If you put this on your door, be sure to carry your key too. The batteries might die, the suction cups might fail or you might forget your knock. Don't complain to me if someone imitates your knock and steals all your stuff, you've been warned.

For obvious improvements to safety, security and whatever, see the final page of the Instructable.

2) This is not a project for a beginner! Read through it carefully and be sure you understand it before you start! I will not take time to answer questions that are already in the instructions or from people who have gotten in over their head.

(If you think this project is too complex you might go here and sign up for the kit mailing list. The kits will be much more simple than this.)

Sorry about that. Now that that's out of the way, lets get to work.

Step 1: Tools, Supplies, And Skills

(If this all looks too challenging, you might consider signing up to the kit mailing list which, when available, will be much easier and a lot more simple.)


This project will take several hours to complete.


To complete this project you should be able to do the following:
These are important! If you're not sure if you have these skills, read through the entire Instructable and make sure you understand it before starting anything!

  • Basic soldering.
  • Read a basic schematic.
  • Basic knowledge of microcontrollers (I'll be using the Arduino.) This means you know what one is, how to upload data to it, and how to make minor changes to code.
  • Improvisation. There are many ways to do this project, and you will have to make changes based on how your door and lock works.


  • Drill (ideally a drill press) and an assortment of drill bits.
  • Saw capable of cutting PVC pipe. (ie: Pretty mcuh any saw.)
  • Soldering iron and solder.
  • Pliers.
  • Screw drivers.
  • Heat-shrink tubing and/or electrical tape.
  • Wire stripper.
  • Vice.
  • Safety glasses.
  • Gloves.

Other things you might find handy: a ruler/tape measure, a multimeter, a breadboard, some tape, a magic marker, sand paper, files, hot glue. And if you're like me a well stocked first aid kit.


(The links are for example only, I don't necessarily recommend or have experience with any of these vendors. Feel free to suggest other sources in the comments.)


  • 1 Arduino Duemilanove (Or compatible. Or really any microcontroller with at least 1 analog input and 3 digital outputs.) Buy from here, here, or here. And other places.
  • 1 5v Gear reduction motor. The higher torque the better. Here's a good one. (14-16mm diameter is ideal because it fits inside of 1/2" PVC pipe.) I recommend one with at least 15oz/in (11 N-cm) of torque at 5v to turn a basic lock. 1
  • 1 Piezo speaker. (30mm) similar to this. You can use larger or smaller ones, smaller will be less sensitive.
  • 1 SPST momentary pushbutton. (normally "off")
  • 1 Red LED
  • 1 Green LED
  • 1 NPN Transistor P2N2222A like these or these (or similar).
  • 1 Rectifier Diode (1N4001 or similar) this or this will do.
  • 1 2.2k ohm resistor (1/4 watt)
  • 1 10k ohm resistor (1/4 watt)
  • 1 1M ohm resistor (1/4 watt)
  • 2 560 ohm resistor (Or whatever will run your red and green LED's at 5v. How to tell.)
  • 1 small piece of perf board. 5x15 holes or longer. (example)
  • 1 9 volt battery clip and 9v battery. (Or any other way you can think of to get 7-12v to the Arduino. A wall adapter like this is a great option so you don't have to worry about batteries running out. 6 AA's would be another option for longer lasting power, but it will bring down the suction cups.)
  • Connector wire. 20 gauge or narrower flexible wire in a number of colors for connecting the electronics together.

It's also a good idea to have a breadboard for setting up and testing the circuit before you solder it. We'll be doing this in step 3.


(These items are to make the project as pictured. Feel free to build a completely different and more functional case.)

  • 20" PVC Pipe 1/2".
  • 3 right angle 1/2" PVC connectors.
  • 1 5-way 1/2" PVC connector. (example)
  • 2 1/2" PVC end plug.
  • 3 1 1/2" suction cups. (Available at hardware stores and craft centers.) NOTE: If your door is unsuitable for suction cups then replace these with three end caps and you can use adhesive strips or screws to mount the lock.
  • 6" of 1/2" wide by 1/64" thick metal strip (steel, tin, copper, etc.) (available at hardware, craft, and art supply stores.)
  • 4.5" of 1" wide metal sheet, 1/32" thick (steel, tin, copper, etc.) (available at hardware, craft, and art supply stores.)
  • 2 3/32" x 3/8" screws with nuts. (1/8" will work too if you can't find the smaller ones.)
  • 2 1.6M (metric) 16mm screws. Ideally with countersunk heads if you can find them. (For securing the motor. Check your motor specs to see what screws it needs. One motor I tried used 1.6M, the other 2M. You'll probably have to buy long ones and cut them to length.)

1 If you have a torque meter or a torque wrench, apply it to your door lock to get an idea of what torque it will take to open your lock. Use a online conversion tool to convert between foot/pounds, N/m, etc.

<p>Cheers, I turned this into a geocache, and built it into a ammo can =)</p><p>https://www.youtube.com/watch?v=ufI1bx3c7rg</p>
I have made a prototype, still have to assemble it to my door. I used a self made relay module to power my motor. Thanks for the instructable...... it works like a dream.
<p>My version is installed in a fridge and using an electromagnetic lock - keep those office thieves away! </p><p>http://ink361.com/app/users/ig-240858804/jas_cal/photos/ig-870056726990911200_240858804</p>
<p>Guys - thank you for this tutorial! I used the code to program a secret sliding library door project and it works great. The secret knock is the part people like the best. People giggle when I show it to them. I owe you a beer!</p><p>http://www.instructables.com/id/Automatic-Secret-Library-Door/</p>
Fantastic work! I love how well the bookshelf hides your secret room. Never would have guessed it was a pocket door.<br><br>Thanks for sharing!
<p>Here we are! Finally done after months of procrastination! I added a buzzer and a third led (not in the picture). The code was changed very slightly but it works perfectly. A latch in the back hangs it on the door. I must thank you, however for the genius of this invention.</p>
<p>hi sir, how did you do this one. where do i put the new code for the led and the piezo.. please, needed for a presentation, our prof. did not give us enough time to master this. and it serves as our final exam.. thank you in advance..</p>
<p>Beautiful work! Thanks for sharing!</p>
<p>here is my little one in an iphone box<iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/HhrNM2kSQzk" width="500"></iframe><br></p>
I have modified the Arduino code to add the functionality of ''Users''. What it does is that it let you program a secretCode for four users. For example: If you push the button X times, after 4 seconds the green LED will blink X times and then you enter program mode (simply do your secret code). I also added the functionality to take a picture when your sequence is bad with LabVIEW and a WebCam camera. Then the picture is saved in my folder and pictures are incrementing with numbers.
Looks great, and really nice added features! I had done a version with his &amp; hers knocks, but this goes well beyond that!<br><br>Fantastic job!
I saw your project some time back and I thought it was great. I decided to take it and improve on it, the result was a system that locks and unlocks. Also if a person inputs an incorrect knock, the system will send a signal via bluetooth to a computer terminal to snap a picture and save it.<br> <br> <a href="http://www.youtube.com/watch?v=6k6XwyB8Hh0">http://www.youtube.com/watch?v=6k6XwyB8Hh0</a><br> <br> Check out the vid. Hope you like it.<br>
That really made my week! It looks fantastic and works great. And the bluetooth camera is a great idea of added security.
Hi Steve!<br /> As you know, I already started to do mine, with a few modifications. I uploaded a new video with a new option:<br /> <object height="344" width="425"> <param name="movie" value="http://www.youtube.com/v/d-HtuH90IMw&amp;hl=en_US&amp;fs=1&amp;hd=1" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /><embed allowfullscreen="true" allowscriptaccess="always" height="344" src="http://www.youtube.com/v/d-HtuH90IMw&amp;hl=en_US&amp;fs=1&amp;hd=1" type="application/x-shockwave-flash" width="425" /></object><br /> <br /> As soon as I finish my project I'll post the code online<br />
Did you finish yet?&nbsp; Can't wait to see the code.<br />
Fantastic work with the servo and the unlock option. &nbsp;(And an off&nbsp;switch!)<br /> <br /> It looks like your setup is really sensitive. &nbsp;Really nicely done! Your&nbsp;achievement&nbsp;patch is on the way!<br />
I have been playing around with this code for the past hour or so and found out how you can hard code in your own rhythm if need be.... at the part that looks like this<br /> // If we're recording a new knock, save the info and get out of here.<br /> &nbsp; if (digitalRead(programSwitch)==HIGH){<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i=0;i&lt;maximumKnocks;i++){ // normalize the times<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; secretCode[i]= map(knockReadings[i],0, maxKnockInterval, 0, 100); <br /> <br /> add this little guy<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.println(secretCode[i]);<br /> and open up your serial monitor....<br /> make sure you un-commented the serial begin up at the setup and then it should spit some numbers back at you... put these numbers into the array and enjoy.<br />
<object height="344" width="425"> <param name="movie" value="http://www.youtube.com/v/zBNTQkVUHvw&amp;hl=en_US&amp;fs=1&amp;" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /><embed allowfullscreen="true" allowscriptaccess="always" height="344" src="http://www.youtube.com/v/zBNTQkVUHvw&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" width="425" /></object>Whoot finally got my relays for my motor and heres a neat little Idea for your visual feedback....<br /> <br />
<object height="344" width="425"> <param name="movie" value="http://www.youtube.com/v/ZGCkVcrUNXM&amp;hl=en_US&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /><embed allowfullscreen="true" allowscriptaccess="always" height="344" src="http://www.youtube.com/v/ZGCkVcrUNXM&amp;hl=en_US&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" width="425" /></object>&nbsp;
Oh, and for your&nbsp;awesome&nbsp;work you have been added as an&nbsp;official&nbsp;Master of Secret Knocks. &nbsp;Your patch is on its way!
&nbsp;This is awesome! &nbsp;Thanks for sharing your code and video. &nbsp;Having the door unlatch too makes it that much more mysterious. &nbsp;And I like the feedback through the peephole.<br /> <br /> Great work!<br /> <br /> And if I ever have any questions about taping something to something else I'll be asking you. :)<br />
<p>sir can you show me the image how all the wire been soldering.....i dont know how to solder which wire...can please show full image the board that you solder...thank you sir...</p>
<p>This project is awesome.i made it but i want to store the new password in EEPROM.Can you please tell me how to edit the code so that it stores the new password in EEPROM.</p><p>Thank you,</p><p>Aamir</p>
<p>Hi,</p><p>I really liked the idea and stuff. I want to make it for my class project. I need a kit as early as possible as I have to submit it by 11/30/2015. Can anybody tell me how can I get the kit quickly? </p><p>Thanks for your cordial help in advance.</p>
<p>I noticed that if I power cycle the arduino, it looses the knock pattern.</p><p>Is there a way to have it save the pattern so it doesn't get lost in case of a powercycle?</p>
<p>Can i do it on atmega 8?</p>
<p>Can it be made without the arduino? I plan on making it as a college project and I can just use an PIC18F45K20</p>
<p>Good one!</p><p>manoj</p><p>www.nrdcentre.com</p>
bro do u hav the codingfor the reset button
<p>Can I use a side button to generate a <strong>auto lock</strong> function?</p>
i would use it in the school locker
<blockquote>how to open it <strong>inside ?</strong></blockquote>
<p>how to control inside?</p>
<p>I really want to see a code and parts list . Can you give me a code and parts list? <br><a href="mailto:woong0111@koreatech.ac.kr" rel="nofollow">woong0111@koreatech.ac.kr</a> <br>Thank you</p>
Great job
<p>First of all, congratulations for this nice project.</p><p>Grathio, i'm a Brazilian student and i'm going to develop a similar object using Arduino at school, but i have one doubt. How can i use a digital knock sensor instead an analog piezo sensor? Is it very difficult to convert your code (using analog entries) to a code with digital entries(like ky-031)?</p><p>Thanks</p>
<p> Here's an adjunct idea for those more paranoid. As long as an arduino is employed, one can add an keypad for entering a secret code. But the code is not correct if it is not punched in on the right cadence.</p>
<p>For the lock clamp...why not get a large piece of PVC (large enough to encompass the lock), and then fill the innards with some sort of hardening putty. Press your lock knob into the putty enough to make a perfect indent, then let the putty harden. Then mount the motor to this somehow. Or you could use putty to make a mold of your knob, and make it from something stronger, like cast aluminum.</p>
<p>Geeeze, Just when I was about to give up on instructables because of the endless dumbass projects using duct tape and making fudge this brilliant piece of irreverent mind expansion comes along - faith restored - thanks! </p>
<p>Nice, you should enter it in the home automation contest!</p>
<p>can we use arduino uno for knock detecting door lock system?</p>
<p>Yes, any Arduino should be able to handle this. Are you asking if the Arduino can detect if the lock is engaged/on?</p>
Your schematics is the clearst i have ever seen...u rock..ur r an awesome inventor...love u

About This Instructable


1,526 favorites


Bio: Creative swashbuckler. Writer for MAKE Magazine, presenter of inventions on TV, radio, magazines and newspapers. Professional problem solver. Annoyingly curious. Hacker of all things from ... More »
More by Grathio: Book Light Reading Light Video: Making your glove work with a touch screen 60 Second Mobile
Add instructable to: