loading

In this project I mede an door lock (or box lock) that opens when you enter your password and press "#". The servo turns back to the position it was in after some seconds.

Step 1: PARTS & TOOLS

For this project I used:

* Arduino uno ( http://store.arduino.cc/index.php?main_page=produc... )

* 4x4 matrix keypad, can also use 3x4( http://www.ebay.com/itm/4-x-4-Matrix-Array-16-Key-... )

* Arduino PCB shield ( http://www.ebay.com/itm/Prototype-PCB-for-Arduino-... )

* 2x 1k OHM resistors ( http://www.ebay.com/itm/50-Pcs-Carbon-Film-Resisto... )

* 3mm green and red LEDs ( http://www.ebay.com/itm/LOT-OF-20-50-100-3mm-Red-G... )

* Male pin header ( http://www.ebay.com/itm/3pcs-40Pin-2-54mm-Male-Hea... )

* Female pin header ( http://www.ebay.com/itm/New-4PCS-40Pin-Straight-Fe... )

* Servo ( http://www.ebay.com/itm/SG90-Mini-Gear-Micro-9g-Se... )

* Wires ( http://www.ebay.com/itm/50pcs-1007-24-color-PCB-So... )

The tools you are going to need:

* Soldering iron

* Soldering paste

* Soldering tin

* Plier

Step 2: Schematic

Follow the schematic.

Step 3: Solder the Connectors

Solder he connections for the Arduino, kaypad and servo. When you are soldering the connection for the keypad and the servo try not to have it in a place where the programing port on the Arduino UNO touches your soldered places, I did that once and I almost ended up destroying my Arduino because the 5v and the GND got connected together when they touched the programing port.

Step 4: Soldering

Solder the LEDs, resistors and the wires for them, than solder the rest of the wires, try to cut your wires so that they fit nice and smooth on the PCB like shown in the photos.

Step 5: The Door Lock

I mounted my servo on an aluminum plate with an simple lock. unfortunately I did not take any photos when making this but hopefully you will understand how to make it by the photo, its really easy.

Step 6: CODE

Download the code and import libraries. You need to download the 3 Arduino libraries if you don't have them.

* password.h

* keypad.h

* servo.h

THANKS FOR VIEWING!

Ifyou like this project than go check out my channel for more cool projects :)

If you have any questions or tips than post them in the comments.

<p>This instructable is very nice and perfect .</p><p>I made it .but there<br>is a problem in the program .</p><p>When you enter password keys and * key<br>the pass is accepted , but after that whenever you press </p><p>Just only * key <br>and no any other key the servo acts ,unless you press another key or<br>rest # key .</p><p>I solved the problem by inserting this line <strong> password.reset(); </strong></p><p>by this when password is accepted the program automatically resets it . </p><p> <br>Serial.println(&quot;Accepted&quot;);</p><p> <br>Serial.write(254);delay(10);</p><p> //Add code to run<br>if it works</p><p> <br>myservo.write(150); //deg</p><p><strong> <br>password.reset(); </strong></p><p> <br>digitalWrite(11, HIGH);//turn on</p><p> delay(5000);<br>//wait 5 seconds</p><p> digitalWrite(11,<br>LOW);// turn off</p>
VERY NICE AND PERFECT
this is my project
<p>i am a begginer will u help me to do this</p>
<p>how i connect the pins for 3x4 numpad ?</p>
<p>Hello everyone, i'm new in arduino and on programming, and when i try to compile he show me some errors like on the image, can you all please hellpe me?</p>
<p>is this the full programming ???<br>and how the programming if i add a lcd or cctv ?<br>can you help me to program it ?</p>
hello , i made the same project , but i want to add buzzer which do a sonor signal when we enter a false password 3 times <br>could someone how can i do it <br>(am asking about the code )<br>
<p>a little doubt here. if i press 123456789 instead of just 159 the opens. i mean the code is such that as if you press any no. having 1,5 &amp; 9 in sequence the door opens</p>
I did not know that, do you have any suggestions to how I can make the code better? <br>Thanks
<p>just test for code entry size, if more than 3 digits, disallow</p>
<p>how would i put that into the code here is the code i have i had tried to do //code entry size, if more than 3 digits, disallow... but it dint nothing and had the same problem</p><p>#include &lt;Keypad.h&gt;</p><p>#include &lt;Servo.h&gt;</p><p>Servo servo_Motor;</p><p>char* password = &quot;123&quot;;</p><p>int position = 0;</p><p>const byte ROWS = 4;</p><p>const byte COLS = 4;</p><p>char keys[ROWS][COLS] = {</p><p> {'1', '2', '3', 'A'},</p><p> {'4', '5', '6', 'B'},</p><p> {'7', '8', '9', 'C'},</p><p> {'*', '0', '#', 'D'}</p><p>};</p><p>byte rowPins[ROWS] = { 8, 7, 6, 9 };</p><p>byte colPins[COLS] = { 5, 4, 3, 2 };</p><p>Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );</p><p>int redPin = 12;</p><p>int greenPin = 13;</p><p>void setup()</p><p>{</p><p> pinMode(redPin, OUTPUT);</p><p> pinMode(greenPin, OUTPUT);</p><p> servo_Motor.attach(11);</p><p> setLocked(true);</p><p>}</p><p>void loop()</p><p>{</p><p> char key = keypad.getKey();</p><p> if (key == '*' || key == '#')</p><p> {</p><p> position = 0;</p><p> setLocked(true);</p><p> }</p><p> if (key == password[position])</p><p> {</p><p> position ++;</p><p> }</p><p> if (position == 3)</p><p> {</p><p> setLocked(false);</p><p> }</p><p> delay(100);</p><p>}</p><p>void setLocked(int locked)</p><p>{</p><p> if (locked)</p><p> {</p><p> digitalWrite(redPin, HIGH);</p><p> digitalWrite(greenPin, LOW);</p><p> servo_Motor.write(11);</p><p> }</p><p> else</p><p> {</p><p> digitalWrite(redPin, LOW);</p><p> digitalWrite(greenPin, HIGH);</p><p> servo_Motor.write(90);</p><p> }</p><p>}</p>
hello , i made the same project , but i want to add buzzer which do a sonor signal when we enter a false password 3 times <br>could someone how can i do it <br>(am asking about the code )<br>
hello , i made the same project , but i want to add buzzer which do a sonor signal when we enter a false password 3 times <br>could someone how can i do it <br>(am asking about the code )<br>which and how can i do it please
<p>can you make the schematic with fritzing? thanks. by the way great project.</p>
hello , i made the same project , but i want to add buzzer which do a sonor signal when we enter a false password 3 times <br>could someone how can i do it <br>(am asking about the code )
<p>why i have error?</p>
<p>You need to install Password.h &amp; Keypad.h from the link in the script. :)</p>
<p>Hello and thank you very much for this topic. I've just made it and it work fine.</p><p>Only one thing seems to be bad : my servo makes some noise and becomes hot during the loop (but not during the 5 sec after be opened). I watch in the code but nothing seems to be wrong.</p><p>Any idea ?</p><p>Thanks a lot</p>
<p>@JbW4</p><p>My servo is doing the exact same thing, have you solved this yet?</p><p>It seems that ibenkos doesn't attend to this comments anymore?</p>
<p>THANK YOU SO MUCH!</p><p>I was struggling with my project and you just saved me! </p>
Your project is awesome but can u connect it with a 16 x 2 lcd module and supply another instructables? Then it would be preciously helpful. Thank You.
Thank you, I dont have enough pins on my arduino uno for that. Maybe it will work with an arduino mega, but i dont have one
<p>IT ALSO WORKS ON UNO JUST CHANGE PINS</p>
<p>I2C LCD only uses 2 pins</p>
<p>Hey, How do you make it so I can add a pushbutton that whenever i press it the servo opens? For the other side of the door</p>
<p>i need to change the lock code numbers within the keypad without connecting to the pc help me by sending the code </p>
That would have been an awesome uppgrade, but I dont know how to make that code :/
<p>you can store code changes in the EEPROM.</p>
Thanks for the code and the project. Can you help me with an issue from which i am suffering from your code :-<br>The code supplied by you stores the password after entering it that is, after entering the correct password and pressing * the lock open but the password gets stored in the system and if anybody will unknowingly press the * button instead of # button then the lock automatically opens.<br>Can you modify the code to auto refresh the password after opening the lock? It is because i have installed this lock at my house door and it will be a funny thing if after opening with the correct password the gate opens all the time by just a * button. I am very pleased with your project and i request the modified version of this code as i am unable to create arduino code because i am new to arduino.<br><br>Thanking you<br>Shayan Das<br>sanu.bullet@gmail.com
Hello, I haven't noticed that there is a bug by pressing *. I will look into the code again and see what I can do :)
<p>maybe....</p><p>void checkPassword() {</p><p> if (password.evaluate()) { //if password is right open</p><p> Serial.println(&quot;Accepted&quot;);</p><p> Unlock();</p><p> } else {</p><p> Serial.println(&quot;Denied&quot;); //if passwords wrong keep locked</p><p> LockIt();</p><p> }</p><p> LockIt()</p><p> {</p><p> Serial.write(254); delay(10);</p><p> //add code to run if it did not work</p><p> myservo.write(0);</p><p> digitalWrite(12, HIGH); //turn on</p><p> delay(500); //wait 5 seconds</p><p> digitalWrite(12, LOW);//turn off</p><p> }</p><p> Unlock()</p><p> {</p><p> Serial.println(&quot;Accepted&quot;);</p><p> Serial.write(254); delay(10);</p><p> //Add code to run if it works</p><p> myservo.write(150); //deg</p><p> digitalWrite(11, HIGH);//turn on</p><p> delay(5000); //wait 5 seconds</p><p> digitalWrite(11, LOW);// turn off</p><p> delay (15000); //wait 15 seconds for door to open and then close</p><p> password.reset();</p><p> LockIt();</p><p> }</p>
Its not a bug actually. After entering password we need to press the * button as it acts as the enter key.
<p>Hi, I have also noticed this problem, But you could simply fix this by pressing the # key on the keypad or the small red reset button on the Arduino, depending on which one suits you best. Both of these buttons clear the previously entered codes and the star key doesn't work on its own anymore.</p>
<p>Once you enter the password, you need to reset it or else someone can just press the enter key to unlock. </p>
<p>All he would need to do is password.reset() when the door relocks..</p>
<p>Im having that error : warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]</p><p>Password password = Password( &quot;0000&quot; ); //password to unlock, can be changed</p><p>How can i solve it ?</p>
<p>I live in a dorm room and often forget my ID to open my door, is it possible to use this to pull down a door handle. How much weight can a servo pull? Does it rotate enough to turn a handle?</p>
<p>what parts of this code do I not use..what else do I have to write to get it to work with rotary phone. Have so many things to make need serious help with code!</p>
<p>I'm tring to use rotary phone as encoder would like to put a lock code in tring everything. Totally lost need some guidance please!</p>
<p>Hey I tried using the code and I got an error about the password event</p>
The green light isn't lighting up. ;-;
<p>PROGRAM is wrong it shows an error </p>
The program works fine, what kind of error do you get?
Compiling error
<p>Tell me the exact words that are printed out.</p>
<p>I've got a short question: is it possible to use 2 different codes for 2 different actions. Example with code '123' you turn on the green led. And with '456' you turn on a red led and rotate the servo.</p>
<p>Yes, but you would have to reprogram it. I could try to make a program, if you'd like.</p>
<p>How I can change the password using keypad periodically ?</p><p>can you plz give me the code for that.</p>
<p>If you did that, you wouldn't know the code.</p>

About This Instructable

119,447views

321favorites

License:

Bio: I am always making electronic stuff. I like to do Arduino projects best. more projects coming soon!
More by ibenkos:433MHz 4Ch Remote Controller Wireless Robotic Control  Hack a servo 
Add instructable to: