3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Secret Knock Detecting Door Lock

Secret Knock Detecting Door Lock
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.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Tools, Supplies, And Skills

Tools, Supplies, And Skills
«
  • knock_lock_electric_parts.jpg
  • knock_lock_case_parts.jpg

(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.)

Time:

This project will take several hours to complete.

Skills:

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.

Tools:

  • 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.

Materials:

(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.)

Electronics:

  • 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.
 

 Case: 

(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.

« Previous StepDownload PDFView All StepsNext Step »
212 comments
1-40 of 212next »
Dec 10, 2009. 3:39 AMjosiasfilho says:
Hi Steve!
As you know, I already started to do mine, with a few modifications. I uploaded a new video with a new option:


As soon as I finish my project I'll post the code online
Jan 16, 2010. 6:16 AMTheBestJohn says:
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
// If we're recording a new knock, save the info and get out of here.
  if (digitalRead(programSwitch)==HIGH){
      for (i=0;i<maximumKnocks;i++){ // normalize the times
        secretCode[i]= map(knockReadings[i],0, maxKnockInterval, 0, 100);

add this little guy
          Serial.println(secretCode[i]);
and open up your serial monitor....
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.
Jan 23, 2010. 4:16 PMTheBestJohn says:
Whoot finally got my relays for my motor and heres a neat little Idea for your visual feedback....

Jan 23, 2010. 4:17 PMTheBestJohn says:
 
Jan 28, 2010. 11:42 AMberr08 says:
Did you finish yet?  Can't wait to see the code.
Mar 4, 2011. 8:12 PMbserrato says:
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.

http://www.youtube.com/watch?v=6k6XwyB8Hh0

Check out the vid. Hope you like it.
May 23, 2011. 1:09 PMvinny03 says:
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.
May 11, 2010. 8:46 AMdarthtony says:
Is it possible each time you program a new knock code(on the fly , using the program button)  the arduno stores it in the EEPROM so you dont have to re program it when you reset?
can someone help me with this?
Apr 18, 2012. 9:31 AMKevCarrico says:
awesome... i've got my code reading the EEPROM on power-up and writing to the EEPROM whenever a new knock is programmed.





i also added some audio feedback, for instance a "game show"-like "fail" buzz through a second piezo for a bad knock, and audible playback of a newly-programmed knock in unison with the LED flashes since it seems like listening to the code being played is absorbed by my brain easier than just watching the LEDs (for me, it all stays in the realm of sound).





also, i'm triggering an Electric Door Strike (commonly used in apartment complexes to remotely unlock a door) instead of a deadbolt or door handle... this means less hardware on the door (only the sensing piezo, actually) and the added convenience of simply being able to push the door open (very helpful when one's arms are full of groceries... and/or beer!).





thank you for this brilliant project and your kindness in helping everyone here who seeks to employ this device around the world!
Apr 24, 2012. 12:18 PMKevCarrico says:
lol... all great stuff.

added a "darlington pair" touch switch to a bare metal thumbtack and now the code can be tapped -- silently -- with one finger.

no more neighbors sneaking in and stealing my beer.

thanks again!
Apr 22, 2012. 5:21 PMstephin99 says:
oh my ive got it!!! add a wifi unit and have it text you every time someone enters the code wrong
Mar 8, 2012. 2:41 PMjakejj says:
Disregard my previous comment. The motor won't work. I do however have a micro servo with enough torque. Any tips on writing code so the knock will unlock the door (servo turns 45 degrees) and then a different knock would lock it(servo turns back to original position)? Thanks so much. Fantastic instructable
Mar 8, 2012. 12:32 PMjakejj says:
I bought an experimentation arduino kit that comes with a DC motor. The problem is I dont know whether the motor will work or not. This is the link to the kit.

http://www.adafruit.com/products/170

Thanks so much :)
Feb 6, 2012. 10:03 AMJaslene100 says:
how did you figure out the array pattern for the "shave and hair cut" rhythm?
Dec 21, 2011. 10:16 PMandrewbaker says:
This would be perfect if you had a deaf roommate
Nov 19, 2011. 8:32 PMElectroThinker says:
Can somebody explain to me about line:
int secretKnock [maximumKnocks] = {50,25,25,50,100,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}
this is the initial setup:Shave and a Hair Cut..Is it mean that I can only knock using this type of knock?Then how do I record new knock...
Else,is it really matter if I use any type of program button? I mean NO, NC?
It because my reset button went crazy each time I try to record other knock, it only listen to Shave and a Haircut knock...all the master please help me...
Nov 11, 2011. 9:35 AMElectroThinker says:
Anybody,can you tell me whether I can use arduino with Atmega8-16PC instead of Atmega328P to do this project.And can I use the program that you (Grathio) gave without change anything.It is because they don't have Atmega Duemilanove.
Oct 15, 2011. 1:59 PMetlerd says:
I know little of electronics or arduino. I'm fact, this is my first project. I've put it together, substituting a servo for the gear motor, and a speaker for the piezo. It works great. One problem: the servo seems to be generating some sort of feedback which occasionally interferes with knock detection. For instance, if it's just sitting there, an occasional knock is detected, and if you manually twist or bump the servo horn, a few knocks are detected (which is what leads me to think its the servo). If this happens when I'm knocking, it interferes with the detection of a correct knock sequence.

Any suggestions to prevent this? I'd be grateful!
Oct 4, 2011. 10:48 AMrobker says:
how much wold you sell it for
Sep 28, 2011. 7:12 PMmvillarin says:
i'm from the Philippines and i'm trying to do this project. i try to buy a piezo speaker

and they say to me that the piezo speaker is a transducer. i search for the picture

of a transducer and it is just like a flat thin disc so i decided to buy a 2400 buzzer..

is it ok to use a 2400 buzzer for the speaker?
Oct 1, 2011. 10:11 PMgroger2 says:
it's ok to use 2400 buzzer. I've used that on mine. My problem now is with just like butcher_pro problem. It always sense knock eventhough i adjust the threshold to the max. I've tried the connection on different breadboards but still the same problem. Do you any suggestion?
Oct 1, 2011. 3:30 PMayanez says:
i cannot download the code :/
Sep 30, 2011. 7:19 PMgroger2 says:
I can't find a reduction motor here in our place so I decided to buy a servo motor.

The problem is I don't know how will I connect the servo motor to my circuit

because it has 3 wires. I search about the polarity of the servo motor wires and I

saw that the red wire is for power, black for gnd and white for signal. Can anyone

help me how will I connect those 3 wires to the circuit? I use the same circuit that

is posted here in this project.
Sep 23, 2011. 4:14 AMvaneh taƱedo says:
hello im vanessa from philippines..i am having a mini-thesis today..i really love these sites because it helping me a lot in my thesis..i am doing a light clapper...i want to know the Schematic Diagram of these project...please help me....thanks..:)
Sep 12, 2011. 1:41 PMbutcher_pro says:
Hi people, i have the whole thing up and running, but when i turn the monitor on keeps reading this:
Program start.
knock starting
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
knock.
New lock stored.


Every ten seconds. i know that the knoks are the readings and it seems like the program is running a loop. I tried getting the sensitivity threshold up to the limit but any threshold variations dont seem to change anything. Any ideas?

Thanks for such an amazing project and gretings from Mexico! :D
Sep 20, 2011. 9:17 PMbutcher_pro says:
ok, i got the thing up and running today, was a serious bad conection LOL anyways im up to the record button and found out that a little cable plugged anoe side only to the digital 2 and the othere end NOWHERE, it works as an "antena" and detects the prescence of static fields so you can record without button. This is cool, but i would like to know if some1 knows whats happening :(
Sep 20, 2011. 3:00 PMbutcher_pro says:
Hello, im from Mexico and i loved this project, but im having trouble getting it to work properly. First i want to know if i can use this transistor http://www.datasheetcatalog.org/datasheet/fairchild/KSP2222A.pdf wich is the one im currently using, but i get knock starting, then some knocks then knock stored. But no lights or engine motion whatsoever. I tried switching the threshold up to the maximum but this makes no change at all. i would love some help. i know im doing something wrong, ive doublechecked the resistors and buttons and batterie but everything seems ok to me. Please please some1 help, i know electronics but not very good and i would love to see this arduino project running!!!

Thank u very much! :D
Sep 2, 2011. 2:03 PMbidkar garay says:
respect...for you
Sep 1, 2011. 7:55 AMLorddrake says:
good job. just saw that your knock detector lock was front page on "there i fixed it"

http://thereifixedit.failblog.org/2011/08/31/white-trash-repairs-secret-knock-detector/

CHEERS!!
Aug 25, 2011. 11:22 AMbjarni1995 says:
Great tutorial, i made a prototype of this but i used a servomotor, i found it really easy to edit the code to work with a servo.

-Bjarni
Aug 10, 2011. 8:09 PMElectroThinker says:
can we use other type of knock rather than Shave and a Hair Cut. Because all video related to this project is using the same type of knock. It's make me a little bit confuse. If we just can program it using that knock so what is the secret means?..really interested in this project but lil bit confused.
1-40 of 212next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
187
Followers
14
Author:Grathio(Grathio Labs)
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 computers ...
more »