Instructables
Picture of Secret Knock Detecting Door Lock
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
« Previous41-80 of 266Next »
whitkari41 year ago
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.
snibbalol1 year ago
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. :)
dmarinho1 year ago
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 =\ )
enagel31 year ago
that got my attention

masonson1 year ago
cool next project
hanyc931 year ago
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)  hanyc931 year ago
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.
mrmerino1 year ago
Oh my god, I just realized that putting this in my hypothetical future kid's treehouse would make me the coolest dad ever.
n79c1 year ago
I am having a problem with button - it adds a knock when I release the button - any suggestions? Everything else works.
Grathio (author)  n79c1 year ago
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 Grathio1 year ago
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)  n79c1 year ago
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.
n79c1 year ago
Hi Can I please have the code that will use a server motor and will lock and unlock?
SubEclipse1 year ago
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.
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.
twighahn1 year ago
could you dummy this down for me?
twighahn1 year ago
would you please dumy this down for me i think it would be a great idea for a panic room
How can I modify the Code to work with a servo?
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)  englishfire1 year ago
>"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.
yozarseef2 years ago
I have some difficulties designing a model with locking ability .. any help please? I will be thankful
KGuy2 years ago
Is it basically the same with arduino uno?

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

Nice job!
cmelad2 years ago
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.7oka4 years ago
hey.. sorry to bother you again.. I just want to know what the function (map(knockReadings[i],0, maxKnockInterval, 0, 100); does..
Grathio (author)  eng.7oka4 years ago
Arduino reference for the map() function.

This normalizes the data so the longest time between knocks gets "100" and the rest are adjusted proportionately.  We do this so it doesn't matter if you knock fast or slow as long as you get the rhythm correct.
I read that in the comment.. but the thing is I'm programming usuing another language.. so I need to understand the mathimatical algorithm behind it.
Grathio (author)  eng.7oka4 years ago
The best description of what it does is in the link I provided to the description of the function in the Arduino Reference manual.
this is the function

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
area362 years ago
My motor is getting no action. I have tried it on the 5v and vin pins along with switching the diode and still nothing. Anyone know whats wrong?
bmondor2 years ago
where do the positive ends of the LEDs go. also i only have 2 wires that go into the digital pin in the arduino. i cant figure out how to get it to work even though i have all the wires in which seem to be the right places.
darthtony4 years ago
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?
Grathio (author)  darthtony4 years ago
Yup, it is possible, and a good feature. Here's an outline of the changes you'll need to make:

- in Setup()  you'll need to read the data from eeprom. (If there is any.)
- in the validateKnock() function (around like 208) you'll need to write the info to eeprom.  You could do it as part of this code loop:

 for (i=0;i>maximumKnocks;i++){ // normalize the times 	secretCode[i]= map(knockReadings[i],0, maxKnockInterval, 0, 100);  	// Write the value of secretCode[i] to EEPROM here // } 
Here are examples of how to read and write EEPROM.

You also might want to look at the code for my Rock-Paper-Scissor Playing Glove for an example that saves and reads info to/from the Arduino EEPROM.
Grathio (author)  Grathio4 years ago
 Gah.  Instructables is still eating preformatted text.  Lets try the code again:
 for (i=0;i>maximumKnocks;i++){ // normalize the times
 	secretCode[i]= map(knockReadings[i],0, maxKnockInterval, 0, 100); 
 	// Write the value of secretCode[i] to EEPROM here //
 }

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!
electricStrike.jpg
Grathio (author)  KevCarrico2 years ago
Fantastic work, thanks for sharing!

We've been playing with electric door strikes as well. They're obviously more invasive (you have to install them in the door frame) but they work much better. You can even mount the knock sensor somewhere other than the door if you want to be extra sneaky. (Or if you're using it to open a secret door hidden by a book case.)
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!
stephin992 years ago
oh my ive got it!!! add a wifi unit and have it text you every time someone enters the code wrong
jakejj2 years ago
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
jakejj2 years ago
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 :)
Jaslene1002 years ago
how did you figure out the array pattern for the "shave and hair cut" rhythm?
« Previous41-80 of 266Next »