Secret Knock Detecting Door Lock by Grathio
Featured
title_image.jpg
knock_lock_side_view.jpg
knock_sensor_bb.jpg
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 1: 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.

1-40 of 241Next »
josiasfilho says: Dec 10, 2009. 3:39 AM
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
Grathio (author) says: Dec 10, 2009. 12:53 PM
Fantastic work with the servo and the unlock option.  (And an off switch!)

It looks like your setup is really sensitive.  Really nicely done! Your achievement patch is on the way!
TheBestJohn says: Jan 16, 2010. 6:16 AM
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.
TheBestJohn says: Jan 23, 2010. 4:16 PM
Whoot finally got my relays for my motor and heres a neat little Idea for your visual feedback....

TheBestJohn says: Jan 23, 2010. 4:17 PM
 
Grathio (author) says: Jan 24, 2010. 12:24 PM
 This is awesome!  Thanks for sharing your code and video.  Having the door unlatch too makes it that much more mysterious.  And I like the feedback through the peephole.

Great work!

And if I ever have any questions about taping something to something else I'll be asking you. :)
Grathio (author) says: Jan 24, 2010. 12:38 PM
Oh, and for your awesome work you have been added as an official Master of Secret Knocks.  Your patch is on its way!
berr08 says: Jan 28, 2010. 11:42 AM
Did you finish yet?  Can't wait to see the code.
Grathio (author) says: Sep 7, 2010. 3:23 PM
I really like your take on it, thanks for sharing!  Your patch is on the way!

(And here's the video embedded for everyone else to see.)
bserrato says: Mar 4, 2011. 8:12 PM
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.
Grathio (author) says: Mar 5, 2011. 8:45 AM
That really made my week! It looks fantastic and works great. And the bluetooth camera is a great idea of added security.
vinny03 says: May 23, 2011. 1:09 PM
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.
Circuit sur porte.JPGMontage.JPG
Grathio (author) says: May 24, 2011. 5:59 PM
Looks great, and really nice added features! I had done a version with his & hers knocks, but this goes well beyond that!

Fantastic job!
cstawell says: May 19, 2013. 2:44 AM
brilliant, I think my little girl would find this a brilliant toy, XD
Andsetinn says: May 8, 2013. 1:38 PM
Very interesting idea and well executed. I've been thinking of putting similar system on the doorbell in my apartment building so that ringing the bell in a certain pattern would open the downstairs door.
There are security issues that stop me. :(
whitkari4 says: May 4, 2013. 7:32 PM
My senior project team just got our device to work with a servo. Yay we plan on adding wifi so that we can figure out how to lock and unlock remotely via a website and mobile application. Once we get everything we plan on posting our code etc for others.
arduino 123 says: Apr 25, 2013. 5:43 PM
I am having trouble pulling up the code, so could you please send me a copy at antonio@deleo.net. Thank you
snibbalol says: Apr 22, 2013. 8:54 AM
My red Light is all ways on so that`is not a good thing right? and another trouble i am having is eaven tho reject value and average reject both are above 80 and my knock is just simple 4 knocks 100, 100, 100, 100, 0, 0, 0,.... etc my device wont regonize the knock as right one and wont do anything to motor what so ever could someone please assists me with this issue since i would need to complete this work by the end of this week / begin of the next week. thank u so much beforehand. :)
dmarinho says: Apr 15, 2013. 9:16 AM
hey, newbie here, can someone upload the code to the lock and unlock system? also the gear motor, does it hold the key or you got to put the device literally inside the door?(sorry for bad english =\ )
enagel3 says: Mar 23, 2013. 9:39 PM
that got my attention

masonson says: Jan 20, 2013. 2:39 AM
cool next project
hanyc93 says: Jan 6, 2013. 1:15 AM
Does anyone know what is the use of the diode? I know it allows current to flow in one direction only but when I remove the diode, the motor still can turn properly.
Grathio (author) says: Jan 6, 2013. 9:59 AM
It's called a Flyback Diode and you really want to keep it in there. Electric motors generate spikes of current when they're stopped and the diode is to protect that current from feeding back into the rest of the circuit, destroying the Arduino or whatever other circuitry you have attached. It's the 3¢ part that will save you $300.  Read the link above for much more information.
mrmerino says: Dec 10, 2012. 1:13 PM
Oh my god, I just realized that putting this in my hypothetical future kid's treehouse would make me the coolest dad ever.
n79c says: Nov 28, 2012. 5:07 PM
I am having a problem with button - it adds a knock when I release the button - any suggestions? Everything else works.
Grathio (author) says: Nov 29, 2012. 8:57 AM
This is just a guess, but I suspect that releasing the button causes enough physical movement that it registers as a knock. To fix it I'd try one of these:
- Reduce the sensitivity (see step 2)
- Use a button that has softer action.
- Move the button further from the sensor.
- Physically insulate the button so vibrations aren't transfered to the sensor.
- Be really really gentle when releasing the button.

It's possible that the switch is very electrically noisy and is putting a spike somewhere that puts garbage into the circuit, in which case changing to a different model of button would help.
n79c says: Nov 29, 2012. 9:05 PM
Hi
Thanks for responding - no I am a dork! I watched your youtube and realized that I released the button too soon. When I waited until both lights went on it was ok. My bad.It is finished and boxed you and working great. Thanks
PS any chance of getting the unlock/lock code that someone said they did?
Adam
Grathio (author) says: Nov 29, 2012. 8:57 AM
This is just a guess, but I suspect that releasing the button causes enough physical movement that it registers as a knock. To fix it I'd try one of these:
- Reduce the sensitivity (see step 2)
- Use a button that has softer action.
- Move the button further from the sensor.
- Physically insulate the button so vibrations aren't transfered to the sensor.
- Be really really gentle when releasing the button.

It's possible that the switch is very electrically noisy and is putting a spike somewhere that puts garbage into the circuit, in which case changing to a different model of button would help.
n79c says: Nov 27, 2012. 5:03 PM
Hi Can I please have the code that will use a server motor and will lock and unlock?
SubEclipse says: Oct 10, 2012. 10:51 AM
I'm in the early stages of attempting this build, and am gathering all the necessary parts.

I can't come up with a motor locally, and have been looking online. Everything I find online is either coming from China or Canada and was hoping to find something located in the US.

The Solarbotics GM22 used as an example looks great, though a little expensive... I couldn't seem to find these offered by anyone other than the manufacturer (also in Canada).

If someone could point me in the right direction, I would greatly appreciate it.

Thanks.
SubEclipse says: Oct 21, 2012. 5:51 PM
I got this all wired up on a breadboard tonight and it's working perfectly (substituting the gear motor with a LED for now). Now I just need to track down a decent motor and put it all together. I'm about to break down and order the one from Canada, since I can't seem to find any decent ones offered from US vendors.
twighahn says: Oct 15, 2012. 12:50 PM
could you dummy this down for me?
twighahn says: Oct 15, 2012. 11:48 AM
would you please dumy this down for me i think it would be a great idea for a panic room
englishfire says: Sep 17, 2012. 10:19 AM
How can I modify the Code to work with a servo?
englishfire says: Sep 16, 2012. 11:05 AM
Why to you use a 9v battery? Why is 5,5v from the arduino Not enough?

In which way do I have to change the code if the motor should move to the origin position after a view minutes?

Greetings from Germany
Maik
Grathio (author) says: Sep 17, 2012. 10:13 AM
>"Why to you use a 9v battery?"

For two reasons. 1) The motor doesn't create enough torque at 5v to turn the lock. And 2) The 5v pin on the Arduino can only safely pull about 200mA. The motor can pull over 500ma under load. This keeps the voltage regulator on the Arduino from burning out.

>"In which way do I have to change the code if the motor should move to the origin position after a view minutes? "

This is not a simple change and would require more circuitry to allow the motor to turn the other way. (Typically an H-Bridge is used for this.)

A simpler way to do this would be to use a servo to turn the lock since they're naturally high torque and can turn either way without extra components. I don't have an Instructable for that yet, but do a web search for "Secret Knock Gumball Machine" to see how that would work.
yozarseef says: Aug 18, 2012. 11:27 PM
I have some difficulties designing a model with locking ability .. any help please? I will be thankful
KGuy says: Aug 17, 2012. 1:23 PM
Is it basically the same with arduino uno?

If it is I could make it today.......

Nice job!
cmelad says: Aug 11, 2012. 10:39 PM
good day sir, I was just wondering if you can give any recommendations or possible innovations for this project. I am studying engineering here in the Philippines and I want to make this as a final year project. my teacher demands for an innovation and I cannot think of any.
eng.7oka says: Jun 5, 2010. 8:15 AM
hey.. sorry to bother you again.. I just want to know what the function (map(knockReadings[i],0, maxKnockInterval, 0, 100); does..
1-40 of 241Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!