Arduino Combination Door Lock: Lockduino




About: 19 year old hobbyiest and future EE.
Ready to put a combination lock on your door to keep out intruders? You've come to the right place! In this i'ble I will show you step by step how to make a combination lock for your door!

Watch this video of the finished product!


What did you make?
Hi, I'm 15, and I made Lockduino! It's a lock that is controlled by 4 potentiometers and a pushbutton. It may also be controlled by IR in the future :?
I just used some perf board, ribbon cable and basic electronics to make it. I got so mad with the perf board (my dremel is very tiny and doesn't cut well) so I brandished my oscillating saw and zzzzzzzip! Whoops! Maybe next time I should be a little more careful ;-).
How did you make it?
Tell us how you got the idea for the project.
We were staying a rental cabin in the mountains for the weekend and I was utterly enthralled by the electronic keypad that you typed in your cabin code to get it. You type in the code and heard, "WRRAANT" and the door popped open. So I decided to make one; modified. Hence I present to you: Lockduino! 
Did you work with anyone else?
Nope. Just me!
Did your plan and ideas change as you worked on the project?

No, not really. I pretty much stuck the same plan the whole time.
Where did you make it?
I made it all in my room on my electronics work table and downstairs by our computer (for programming Arduino).  A lot of running up and down the stairs!
How did the project connect to other activities in your life?
Well, it keeps out my friends when I don't want them in my room, it keeps my stash of equipment safe and sound!
What did you learn?
What I learned was how to properly use if statements with Arduino. It took some time  but I got the hang of it. You can see this thread to see how I was in misunderstanding about how to construct my if statements!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Ingredients:

  • Arduino
  • Micro servo
  • Green LED
  • Red LED
  • (2) 350 ohm reistors
  • 10k ohm resistor
  • (4) 10k, 50k, or 100k micro potentiometers (the higher the resistance the better
  • Perf board
  • Momentary pushbutton
  • 2.54 cm. pin headers
  • Insulated jumper wire
  • Heat shrink
  • Ribbon Cable
  • 9v battery and clip
  • 4 AAA battery holder
  • Soldering pencil
  • Tool to cut perf board (I found that the oscillating saw works the best!)
  • Razor blade
  • Wire cutters
  • Wire strippers
  • Needle-nose pliers
  • Electrical tape
  • Helping hands are helpful!
  • Hot glue gun
  • Heat gun
  • Sharpie
  • Paper and pencil
  • Drill with 1/4  bit, and 3/8 bit.
  • Insulated ring terminal
  • Basswood or 1/4 ply
  • Double-sided tape

Important Terms:

  • Block - Any code in between two brackets; for eg. { code here } 'code here' is "in the block."

Step 2: Prepping the Perf

How many times have I said prepping the perf? 
Anyways we're going to get started my drawing out a little template for the 2 LEDs (or one if you have RGB LED) and for the pots. I spaced the pots about 1 1/2 inches apart. Just keep in mind that you have to leave enough room for your turning knob. Cut out your template and solder all the components to it.
To connect all the potentiometers; begin by making a jumper like the one shown in picture 7. You don't have to do this, you could just use a insulated wire like I did with the positives. All the negatives (left side) connect together. Connect all the positives (right side).
Now, VERY IMPORTANT! TEST! You don't want to finish the project and then go, OH NO, it's not working!!!
To test, hook up the red wire (from the perf board) to 5v on Arduino and the black to GND. Connect your multimeter's black test lead to GND. Connect the red wire (of the multimeter) to the middle pin of the pots. Turning the pot should give you a read of 0 volts through 5 volts.
Make sure that when you solder the pots on they are all level and the same height. Otherwise, you will have horrible problems when it comes to adding the knobs.

Step 3: Ribbon Cable Dissection & Soldering

Ribbon cable! My good friend gave me this from I guess his old computer. Whatever the FD drive is! So, using razor blade, separate 8 wires from the rest. Then I used some wire cutters to cut it. Strip the ends of the wires. 


Working with ribbon cables can be tricky, but I found a way to master it. Draw a diagram! You can see in my diagram (the top) where everything should go. The bottom is just everything reversed because when I was soldering I was soldering with it upside down.

Step 4: Arduino Backpack

This is what others call a "shield", but I like 'backpack'. Now what's the purpose of this? It's so that if you need to use your Arduino for something else, you can just pull it off the top of the Arduino. If you want it back on, you can just push it right back onto Arduino!
Now there is a small problem with the pictures. I didn't put the open button on the inside of the door until later, so you won't see it in these pictures. Instead of making a 4 segment pin header make a 5 segment header.The fifth one will go in pin A4.
  1. Lay the perf board on top of the the Arduino. Then stick some pin headers through the perf and into the Arduino's output pins. This is to hold the perf board on the Arduino. Using a sharpie, outline the Arduino on the perf.
  2. Cut the perf
  3. Mark a rectangle in the middle. Use a dremel to cut it out. I was able to cut it about halfway, then knock it out with a screwdriver.
  4. Cut off the pin headers. (1, 2, 2, 5) 
  5. Place all the pin headers into the Arduino pins. (the 4 goes into pins A0-A3, one of the 2 goes into 5v and GND, the other 2 connects to pins 12 and 13, one of the 1 goes in A4, and the other 1 goes into pin 9.)(see pictures)
  6. Put the piece of perf on top of the Arduino, letting the pins slip in the holes.
  7. Put a drop of solder on top of the pins to hold them in. 
  8. Feed the ribbon cable though the rectangle.
  9. Make all the solder connections. Be careful! Don't forget the resistors, pins 12 & 13!
  10. Cut off the connector of the servo and strip the ends.
  11. Attach the battery pack's positive and negative to the positive and negative of the servo. 
  12. Solder the GND of the battery and servo to GND on Arduino.
  13. Solder the control wire of the servo to pin 9.
  14. Flatten out the tabs of a momentary push button.
  15. Clip one of the leads of a 10k resistor off and solder it to the switch.
  16. Solder a wire to the other end of the resistor.
  17. Solder a wire on before the resistor on the same pin.
  18. Solder a red wire on the other pin of the push button.
  19. Cover all the connections with heat shrink.

Step 5: Testing:

Now testing is always a good thing. It always good to know whether your project is working or not! Upload this code and open up serial monitor. See the video. Serial monitor is on the right. Warning: This is not the final sketch! This is just to test the pots!

Step 6: Making the Front Panel

So I just took a piece of basswood and marked off where all the potentiometers where. Then I took a ruler and drew the same marks in the middle. Using a 3/8 drill bit, I cut drilled the holes for the pots. MAKE SURE then pots fit in and are nice and level! For the LEDs just use a 1/4 drill bit as usual. 

When you are putting on the ring terminals, MAKE SURE THAT THE POT IS TURNED ALL THE WAY TO THE LEFT FIRST!

To do this you need to load the sketch to your Arduino and open up serial monitor. Slowly turn the knob. In serial monitor when it says 1, make your first mark. When it says two, make your second mark etc..
Making a frame-
Using some basswood sticks, I cut them to length and glued them on the edges. See photos.

I attached some double-sided tape to the battery holder, Arduino and the wooden frame.

After yo put the LEDs in sand them down the the height of the holder for some diffusion.

Step 7: Making the Servo Holder

So I'm sure you can use some type of aluminum sheet metal, some type of laser cut acrylic, or 3D printed holder, but I don't have any of those. So I used a metal lid to a game. I was able to use my old pair of scissors to cut it up. BE CAREFUL, THE EDGES ARE SHARP! What I did is kinda hard to explain so just go through the photos one by one. 

Step 8: Final Pictures

Step 9: Breaking Down the Arduino Code

Now the whole point is to learn, right? Now what do we want to happen? See the flowchart above. Let's get started by adding all of the pins.
This is just setting up all the pins. I'm not going to waste any time explaining this.

Setting up the the outputs.

buttonState = digitalRead(button1);
This is setting the words 'buttonState' the the digital reading at pin button1, which is pin A4. Since it's using the digitalRead function 'buttonSate' can either be HIGH or LOW.
int analog1 = analogRead(A0);
This is for taking an analog reading at pins A0. The analog reading is 0-1023.
int pot1 = analog1 * (10.0 / 1023.0);
Convert the analog reading from pin A0 to 0-10 from 0-1023

The rest of the code is for the other analog readings on the others pins A0-A3.
if (pot1 == 4 && pot2 == 5 &&
    pot3 == 3 && pot4 == 6)

Now this is where you need to put you your own combination in. I'm going to make mine 4536. 
This is to test the following: If pot1 is equal to 4, and if pot2 is equal to 5, and if pot3 is equal to 6, and if pot4 is equal to 1, do the following. Change the numbers pot1,2,3,and 4 equal to create your own code. 
   digitalWrite(greenLED, HIGH);
   digitalWrite(redLED, LOW);

Let's add another if statement

elseif (buttonState == HIGH) Is the digital reading at pin A4 high??? Yes, it is! So do. . .

   digitalWrite(greenLED, HIGH);
   digitalWrite(redLED, LOW);

If either of these if statements aren't true, then do the following:

      digitalWrite(greenLED, LOW);
      digitalWrite(redLED, HIGH);  

Now you may have noticed I added a delay in the button block, but not the pot block. Well the reason why I did this is so that you don't have to hold the button. If you look over the code, you will see that there are no delays, so Arduino is constantly doing the loop over and over and over again at a very fast speed. So the code says, "if the button is high, unlock the door'. Well if you release the button, the loop is looped and it sees the the button is not HIGH, so it locks the door. With the delay, once it detects the button is pushed, it will preform our action (unlocking the door, changing the LEDS), then is wait for 5 seconds before running the loop again. If you don't understand, try it. Take out the delay and see what happens.

Step 10: Final Arduino Sketch

If you can tell the code is 4561. Notice that I change these numbers up a bit from the previous code. Note: You will most likely have to change the servo values. Start off with 90˚ and slowly work your way up and down. You don't want to break your servo! For powering the Arduino I used a USB cable and a USB cell phone charger so I could have my lock constantly running!

Step 11: Conclusion:

I hope you guys enjoyed this i'ble! If you like it, vote it as a winner for the UP contest and the Make-to-learn Contest!
Please post your pictures of yours and if you have any question leave them in the comment box below or PM me.

I didn't think about adding the pushbutton until after I had finished the project, so I'm sorry that some of the pictures don't align with the text.


Make-to-Learn Youth Contest

Fourth Prize in the
Make-to-Learn Youth Contest

UP! Contest

Participated in the
UP! Contest

Be the First to Share


    • Assistive Tech Contest

      Assistive Tech Contest
    • Reuse Contest

      Reuse Contest
    • Made with Math Contest

      Made with Math Contest

    56 Discussions

    Neel Dhebar

    4 years ago on Introduction

    Interesting project with the Arduino but there are several thing I'd like to point out:

    Well, lets face it: anyone will just keep turning the knobs until they can get in so you could add a variable to count the number of attempts and then lock out once say, 5 attempts were wrong. With an Arduino of course you could have a smartphone app that wirelessly communicates with the Arduino and sends a text message if anyone enters.

    The possibilities are endless.

    Keep posting!

    1 reply
    HavocRCNeel Dhebar

    Reply 4 years ago on Introduction

    If you'd like to try then have fun breaking in have fun! That's a good idea though! At the time I barely new about electronics so that was all I knew about. I may make a second version. . .


    5 years ago on Step 4

    can you please help me.. I followed your connections but my LED lights wont light up and my servo is not functioning properly :( I used this for my elective project..

    4 replies

    Reply 5 years ago on Step 4

    yes I used the ribbon cable.. I passed the project but the LED is still not working but the servo works fine :)


    Reply 5 years ago on Step 4

    I'm glad you passed! Well it's very difficult for me to help you because there are a number of things that can be wrong. Try checking these things:

    1) LEDs are wired correctly, Cathode (shorter lead) to GND, and the

    Anode to the correct pin on the Arduino.

    2) In the sketch make sure which pins the LEDs are supposed to be connected to, then trace your LED connections and see if they go back to the correct pin.

    3) Nothing is shorting out

    4) Bad LEDs

    I'm sorry I can't really help you further, as I cannot see your project. Good luck!


    5 years ago on Introduction

    Hello! Good day. Can I ask for the schematic diagram of this project (Arduino Combination Door Lock: Lockduino). Can you please send it to my email, Thanks!

    1 reply

    Reply 5 years ago on Introduction

    Hey! I just realized that I haven't made a schematic would you please give me a couple of day since I'm busy. I need to make one anyways.


    6 years ago

    I am tired and I didn't read much (and am currently unable to view the comment on this i'ble) so I don't know if you mentioned whether it would be possible to change the code or not... Otherwise, I am 100% impressed by this creation.

    1 reply

    Reply 6 years ago on Introduction

    Ok! I clearly gave instructions on how to make the code and change it! Maybe you should have a nice, long rest, then come back after a cup of coffe and read it again :). I hope you can understand it.


    6 years ago

    i took apart my comuter and found a cable labled "FD" connected to the floppy disc drive

    the computer is still working


    6 years ago on Introduction

    I have built this, but i get a "error compiling" .
    If I remove all the code for the servo it works fine. Any suggestions?

    7 replies

    Reply 6 years ago on Introduction

    Have you installed your Arduino(I think you only need to do this with the Mega 2560 and ADK) correctly? You can do this by (windows) going to device manager and right clicking the unknown device and click update driver software. Then click "browse my computer for software" and browse to the location of your Arduino folder. Once there click on the folder that says drivers(do not expand it). Lastly click open. That should install the drivers. I forgot to install the drivers on my Arduino when I was working with some led and they just did random things.


    Reply 6 years ago on Introduction

    GpaSteve, I just think I know what your problem is. You most likely haven't installed the servo library. Is this true?


    Reply 6 years ago on Introduction

    Servo library is loaded. Will remove and reload and see if that fixes it
    Thanks for the response


    Reply 6 years ago on Introduction

    I'm not sure what your problem is because that's the code that is running on my Arduino right now. Can you take a screenshot of the error and the highlighted text? Thanks!

    And, what is the name of your servo library folder, is it just named 'Servo' or is it something else like 'Servo.h'?


    Reply 6 years ago on Introduction

    Error message:
    Error Compliling
    C:\Users\steve\Documents\Arduino\libraries\Servo\Servo.cpp: In member function 'int Servo::readMicroseconds()':
    C:\Users\steve\Documents\Arduino\libraries\Servo\Servo.cpp:327: error: 'clockCyclesPerMicrosecond' was not declared in this scope

    Folder is servo, servo.h is in this folder.

    Thanks for your assistance



    Reply 6 years ago on Introduction

    Steve I honestly have absolutely no idea what is the problem. You will have to ask a forum.
    Does Arduino highlight any certain text? Can you post a pic of the highlighted text? Thanks.


    Reply 6 years ago on Introduction

    No text is highlighted.
    Thanks for all your assistance. I will ask around.