I've always wondered how did electronic locks work, so once i finished the basic digital electronics course I decided to build one myself. And I´ll help you to build your own!


You could connect it to anything from 1v to 400v(or maybe more that depends on the RELAY), DC or AC, so you could use it to control another circuit, or even to electrify a fence!! (please dont try that, really dangerous)… I connected a mini chrismas tree to the output (110v) cause I hadnt taken the holydays decoration off my lab, so it was around at the time i finished the proyect.


Here are some pictures of the finished System, and a video too, so you can see it working.

Step 1: How Does It Work?

First I thought in what was needed to be processed and how. So i drew this diagram as a map to guide me as i build each part of the proyect. Heres a summary of how it works.
  • First we need a circuit to decode the 10 possible inputs (0-9) to its 4 output BCD (Binary Coded Decimal), and another output that tells us when any button is pressed.
  •  Then we need to build the circuit for our two 7-segments displays to work properly, with 4 inputs for a BCD number and of course 7 outs for our displays, ( I used the IC 74LS47)
  • Then a circuit to save each pressed number and toggle between displays
  • As well as an internal memory for our password
  • And, the hearth of our lock, the comparator (its 8 bits ´cause there are 4 bits per digit in the display, meaning that if you want to do a 4 digit lock you will need two of this connected together.) This will tell us if the numbers in the displays are the same as the password saved in the internal memories.
  • And finally a circuit to keep the OPEN or CLOSE signal for an undetermined time, and of course an output (thats whatever you want to control with your lock)

Step 2: Materials

Here´s all that you will need.
NOTE: I took most of the materials from an old VCR board, so they were "free" making this proyect really cheap. In total i spent about 13 dlls (most of the IC cost 76 cnts, exept for the D-ff (about 1.15) cause i had no IC, but you can keep them for future proyects, they are a great investment.
  • Lots of Diodes (about 20) to make one way connections.
  • One NPN transistor ( to feed the Relay Coil with enough current)
  • One Relay (to control the connected device)
  • One red LED ( to indicate when the system is LOCKED)
  • 14 push buttons
  • Lots of resistors (doesnt really matter the resistance, its just to set the IC pins to 1 or 0[+ or -])
  • Two 7-segments Displays.
  • A Lot of wire!!
Integrated Circuits:
  •  Two 7432(OR GATES) to build the DEC to BCD and the comparator
  •  Two 7486(XOR GATES) soul of the comparator.
  •  Two 7447 Display driver
  •  Four 74175(4 D-FF) each is a memory able to hold 4 bits.
  •  One 7476(2 JK-FF) for the display selector and to hold the OPEN CLOSE signal.
  •  One 7404(NOT GATE) invert the clock pulsefor the display selector. ( you could use an NPN transistor insted, cause you need only one gate ( the ic has 6).
  • 3 Protoboards (http://en.wikipedia.org/wiki/Breadboard)
  • Pliers
  • Exacto Knife
  •  5V DC power supply(feeds circuits)
  • 12V DC power supply(feeds the relay coil)
  • 120V AC Power supply(feeds the device on the output)
NOTE:I used about 8 ft of wire, and advice about this, insted of buying expensive protoboard wire, you could Buy 3 ft of ethernet cable, the strip it, and you will have 8 or 9 wires, each with a diferent color and 3 ft long. (thats exactly what i do, since the normal protoboard wire is about 10 ft per dollar.
But for a buck you could 3.3 ft of ethernet cable, so you would end up with about 27-30 ft!

Step 3: Dec to BCD

The first step is building the input system, so you can comunicate with your lock.
I´ve designed the following circuit in order to achive two main goals.
  • Turn any of the 10 numbers from (0-9) to its BCD (binary) counterpart.(Actually, there is an IC for this purpose, but it wasnt in stock when i went to my local electronic shop., so if you get it you will save yourself a lot of time and trouble, but I think is more fun this way )
  • Being able to detect whenever a button is pressed.
To solve the first problem, we should take a look at this truth table to know which output (ABCD) will be high (1) when we press each button.

D C B  A]  X
0  0  0  0]  0
0  0  0  1]  1
0  0  1  0]  2
0  0  1  1]  3
0  1  0  0]  4
0  1  0  1]  5
0  1  1  0]  6
0  1  1  1]  7
1  0  0  0]  8
1  0  0  1]  9
Now heres where something I love about Digitals comes to a use…
There are many ways of doing one thing…. Its just like maths, you can get to 3 adding 1+2, or substracting 4-1, or 3^1….
In other words, you could build lots of diferents circuits to achive the same goal, this is something that makes our current task easier.
I designed this circuit cause I thought it used few ICs, but you could design your own!
Now, I know some maybe scratching their heads trying to figure out why did I used so many diodes, well here is the answer…
Diodes work like a one way connection, so in a pair connected as in my circuit, if there´s (1) voltage on its "positive side" it will conduce current, so we will have voltage in the other side aswell, but if there is a negative , or inexistent voltage (0) it will behave as an open circuit. Lets check the behavior of these diodes, calling the first diode anode (+) "E", and the second diode anode "F" and the output will be their connected cathode"X".

 E F]  X
 0  0]  0
 0  1]  1
 1  0]  1
 1  1]  1

 You can see we have the exact same behavior than an OR GATE, and then,Why not using just diodes, that way you will save even more Integrated Circuits, and money?...Well the answer is simple, and you should really take it in consideration, the VOLTAGE DROPPED across EACH DIODE. It´s normally about 0.65V. Why is that? Because each diode needs at least 0.6 V across its anode and cathode to make its junction get close, so it can start conducting.I

In other words, for each diode you connect and its working at the same time, you will loose 0.65 V… that wouldnt be a big problem if we were only turning leds on, but we are working with TTL IC, that means that we need at least more than 2 V. And as we are starting with 5 v.. That means that conecting 5 diodes will cause a failure in our circuit ( the integrated circuit wouldnt be able to distinguish between 0v and less than 2v…)
That´s why I never used more than 2 diodes in each input…
NOTE: You must connect a resistor connected to GND in each OR Gate input…
To solve the second problem I just added a diode to each ABCD, and 0, and connected them together, so whenever any of those is 1, you will have a 1 on "Press"(P).
Now all that´s left is to build it on your breadboard, or if you want to save some more space you can do as i did, and drill some holes in a construction paper and solder the diodes and push buttons there...

If you need some more information about Logic Gates:
If you need some more information about diodes:

Step 4: Displays


These step is one of the easiest, we just need to decode the ABCD inputs to drive the seven segment display…And luckly there´s already an integrated circuit that will save us all the logic, time and space.


If you are using a Common Anode display then you will need a 7447.

If you are using a Common Cathode display then you will need a 7448.


The wiring is the same, so either way you could use my schematic.


The inputs ABCD for each IC come from each memory´s output (we will review the memories in the next step)

Step 5: Memory

This is were we change from combinational logic, to secuencial logic…
To make the 4 bits(ABCD) memory we just need a D- Flip Flop for each bit, and in the 74175 we have 4 of those.
Remember each number is represented in ABCD , so each 74175 can save one number.
For more information about how does the D-flipflop works, and how does it saves information,:
The input of the first two memories (Data "D") comes from the DEC to BCD coder that we built on the first step.
Well we have the information that each one is going to hold, but, when are they going to save it?
Of course, one will save the first pressed number and the other the second pressed number…
So, how do we get this effect? Well with another kind of FF (flip flop) the JK, when both J and K inputs are high, it will change the state of the outputs to its complement (negation), in other words, we will have on "Q" 1, then 0 then 1 again, then 0 and so on. This Q and Q´ are the clock for the memories (what will tell´em when to save new data.)
The pulse that will determine when this change is made is the "P" that is high whenever you press any number, but to save the information on time, we will need the opposite, so heres where we use the NOT GATE.
In other words, once we push a button, the jk ff will change its output, turnin on the first memory, so that it will save the data, then we push again and the first memory recording state will be off, but the second memory will save the new data!
I added at this point a reset button that will turn both memories (ABCD) back to 0, and will return the display selector (jk ff) to the first memory.
For more information about the JK FF:
Now… why did i said we need four 74175?
Well to save the password!! While its possible just to set the password with resistors to GND or Vcc, that will make your password static, and impossible to change if you get your lock done in a PCB.
So, with a memory, you can save the password, and change it as many times as you wish.
The inputs will be the outputs of our displays memory, so when a positive pulse reaches their clock, you will be coping whathever numbers are in the displays. (both, the memories and password memories will have the same information). Of course the "new password" pulse will only be avaliable if you already intruduced the correct password and opened the lock.
In all we will have a storage capacity of 2 Bytes or 16 bits!!

Step 6: Comparing

At this point we have a system thats capable of saving each number we press in one display then the other, and copying that information to the password memories… we are still lacking the essential, the Comparator… one circuit that will compare the two (ABCD) of the display memories with the two (ABCD) of the password memories.. Again, theres already an IC from the TTL family that does all the dirty job, but it wasnt in available in my local electronic shop.
So I built my own.
To understand how i did it lets look at the XOR truth table
 A  a]  X
 0  0]  0
 0  1]  1
 1  0]  1
 1  1]  0
Notice that whenever A and a have the same value, the output is low (0).
So if they are diferent we will have a 1 at the output.
Meaning that with one XOR Gate you can compare 2 bits one of the display memory and the other of the password memory. Based on that i built the following circuit, remember that you can build it your own way, cause there are many ways to get to the same answer here in digital electronics.
This circuit takes in the 8 bits of the display memories ( one bit per XOR, cause the other input should be used with the password memory) and the 8 bits of the password memories ( its a 1 Byte comparator).
And will deliver only one output.
 if and only if the information on both display memories is the same as the information in the password memories, we will have a (0) low output. In other words, if the information on both sets of memories differ, even on 1 bit, the output will be high (1).

Step 7: Open/Close

Finally the last part, we are almost done! Soon enogh you will be able to lock any device, or electrify any fence,, ( Please dont!)
Now, we will take the last bit of information, and interrupt it with a push button, so if someone accidentaly writes the correct password, the lock wont open.( i called this button "enter", really clever, huh!,)
And after the enter button,will come the RS latch, one device that can turn Q´ to 1 if a there´s a 0 on its R input, and save it, and Q to 1 if theres a 0 in the S input.
For more information on RS latch:
I connected "Q" to a red led meaning lock, or that the controlled device is OFF.
And "Q´" to a transistor that will provide the relay with enogh current to turn it, turning ON the controled device.
"Q´" was connected to a push button, ( that i called new password button for obious reasons) so that when you push that button it you will close the circuit between Q´ and the clock input for the password memory. If Q´ is Low (system locked) nothing will change in the password memory when the button is pressed, but if it is High (system Open) clock will be activated and password memories will copy the information on the display memories.(changing the password).
And connected a resistor to GND and to a push button (lock button) and from there to the S input, so whenever you press it, you will lock the system.
Well, while i could have bought an RS flip flop just for this purpose, i still got one JK ff left from my 7476.
And, cause the inputs R and S are asincronous, we dont need to worry about the clock. So just wire things up as shown in the diagram ( as i did.)
Be Carefull when you connect the relay to AC, use enough isolating tape.. You dont want a short circuit when working with hundreds of volts!
After conecting everithing together…we are finally done!!! Please feel free to comment any question or suggest, if you notice any problem or mistake dont doubt in ponting it out. Im here to help.
Good lock, i mean, good luck with that lock.
<p>Hello Nino123, one question, You have a complete schematic of the circuit?</p><p>in the images it isn't clear to me</p>
<p>Hi Nino.. do you have a copy of the whole schematic diagram of this project? because i want to build this but im confused how would i connect all of the schematics that you've posted.. thank you! :D</p>
<p>Thank you this is very helpful I have 2 questions.</p><p>1) I did not get how to write data to FlipFlop so that It will be there aways?<br>if we remove power supply will it Earase?</p><p>2) I did not get ho wopen/close worked . can you give more info on that also</p>
<p>I have few questions:</p><p>First, there are only 4 outputs from decoder how did you make them into 2 displays ?</p><p>and second, some of the pins you labeled as upper &quot;A&quot; and lower &quot;a&quot;, I'm so confused, does that mean they are the same input ?</p>
<p>Well, you see, upper and lower case A's are indeed different nodes. Lets review a little, The Decimal to Binary circuit outputs a bus of 5 lines, ABCD which represent the binary number and a clock (sincronous output to tell the circuits ahead to act upon the event of pressing a button). Now I simply used that ABCD from the circuit to 2 memory circuits. they will both recieve ABCD data at the same time, but as they are syncronous they will only change their outputs (hold the data) when the clock signal arrives at the CLK pin in the integrated. So theres where the &quot;display selector&quot; comes in, it simply has two outputs for one input, so when ever it recieves the CLK signal from the BCD circuit, it toggles the outputs, therefore toggling which memory 'saves' the button being pressed. So each time you press a button both memory circuits will have the same data in their inputs, but the extra clk output, toggled in the display select will make possible that only one of the memories hold that data, one different display each time. From there on, memory 1 has ABCD outputs to te display decoder1, to the 7 segment 1. memory 2 has abcd outputs to the display decoder2 to the 7 segment 2. The name of this technique is Multiplexing. </p>
Do you have an email or facebook ?. I've just started to learn digital systems.
I guess its not that crazy just a place to go where you either have nothing to do or you can only read a book or study just distraction free lockdown or a place to break a bad habit or learn to live moderatly kinda like sensory depravation just more like a controled environment it still seems borderline crazy but I think I could relax and focus idk
<p>Not crazy at all bro, sometimes the world is just too noisy, how can we read a good book, enjoy good music or just plain think about our own life?, Sounds like a good proyect, but i personally think that is kinda dangerous to do the lockdown system yourself... Even if you are a PRO at electronics, what if something goes wrong? I recommend you build the safe room yourself and everything else inside, but things like ventilation, electricity internet and locks get a professional :D</p>
This might sound uber insane but sometimes I just need to be locked up for my own good. I was considering using a vault like room kinda like a bomb shelter i have on my property and locking it from the inside with a digital countdown timer able to set for 10 to 14 days mabe longer controlling a electronic door lock somthing like a timed safe only for me. mabe insane could be useful. During this time would need food and water rations dispensed in appropriate amounts was thinking most simple failsafe system if anyone knows of anything or any instructables realated or can help please do
nino, how to connect all this circuit? especially the display memories circuit. I don't understand it with the internal memories. does it came together in display memories circuit? thank you.
Hey, sorry again for the late reply, finals are killing me, but well thats what you have to go through to be an engineer! Well, about how to connect it... Most of the diagrams I posted, came from a software which not only numbered each pin, but also named it; in order to be able to understan that, you need to know your ICs, and by that I mean reading the datasheet, and understanding the basic operation of your IC, and how to use each pin. I strongly recommend, that you practice easier circuits with each IC, just to get used to the Pinout and the way they work, and then youll be able to make any bigger project using as many as you need, after all, if you learn the alphabet youll be able to write poems, books or just about anything after practicing, the same applies here. <br>The 74175 is just as any other TTL IC, you have to power it with 5v, ground, and in this case, youll have to give it a signal that will trigger the change of state on the outputs(which will remain on that state indeterminately), acording to your inputs (which youll control on the keypad) . In this case, the output are coded to BCD, and then translated from that to a 7segment display &quot;language&quot; by our 7447
I'm sorry. actually I posted once only. Don't know how it repeated again. By the way, thank you very much for your explanation. I will seek your advice if I stuck at somewhere later. :D Thank you once again.
this is my new account from azaki-1. thank you.
hi. I have same project with you where I have to build digital combination lock. I just want to confirm with you which is my project need to enter 4 numbers, and reconfirm again the number input. If correct, then it will light up GO LED. if not, NOT GO LED. So, it is my project almost same to you or not. Thank you in advance, and really need your explanation on your projects.
I answered on the last comment reply, but It has been a lot of time since the last time I used Digital circuits, I can totally tell you that using a Pic, PICAXE, Arduino, Parallax, or any other microcontroller would make your whole proyect really easy. Its easier to learn how to program (and maybe cheaper) a microcontroller that learning digitals. But if you, (like in my case) MUST use Digital Circuits (TTL 74XXX) I hope my proyect serves as a guide, If you really need more help, you can send me a Personal Message, Ill try to answer as soon as I can, just be patient, Im an engineer student, I have not a lot of free time.
hi. I have same project with you where I have to build digital combination lock. I just want to confirm with you which is my project need to enter 4 numbers, and reconfirm again the number input. If correct, then it will light up GO LED. if not, NOT GO LED. So, it is my project almost same to you or not. Thank you in advance, and really need your explanation on your projects.
Yes it really almost the same. On the output, the led that will go or will not go out is just the same as my Relay for 110v, instead of wiring the relay to the output, just connect the led directly where the Q or Q' depending on your case. If you want it to be a 4 number combination lock, youll have to add two more displays, decoder(7447), memory(74145) and comparation blocks (7486). To make it double confirmation, you can add another flipflop (7476) before the led, so youll need two &quot;clocks&quot; (correct number on the input) for your last jk flipflop to turn the Q' ON.
hi. I have same project with you where I have to build digital combination lock. I just want to confirm with you which is my project need to enter 4 numbers, and reconfirm again the number input. If correct, then it will light up GO LED. if not, NOT GO LED. So, it is my project almost same to you or not. Thank you in advance, and really need your explanation on your projects.
I also would like to ask if you can suggest a circuit with these functions: <br>Code Breaker <br>Three digit code (0-9) <br>Three LEDs for right number but wrong position (red) <br>Three LEDs for right number and wrong position (green) <br>One digit display for the number of tries <br>One increment button for each digit <br>One GUESS button <br>One STORE button for new code <br>Switch debouncing using 555 timers or one shot multivibrators <br>Master reset button <br> <br>thank you very much i would really appreciate it if you would respond with this post...
&nbsp;hey amigo... he intentado tu circuito con un amigo, y tenemos multiples fallas! ...ser&aacute; posible q envies algo de info extra a mi correo? irv_c45@hotmail.com... sobre todo los mapas de conexiones, tengo dudas sobre los puentes q aparecen en el primer mapa, y si existe una sustitucion de los diodos, o cual funcion cumplen (le&iacute; como un OR)... gracias d ante mano!
listo amigo, revisa tu correo electronico, te he enviado una respuesta a tu comentario, si tienes mas dudas, no dudes en contactarme, suerte con el proyecto..<br /> <br /> no he subido mas proyectos, por que actualmente estoy dedicandome a aprender mas sobre microcontroladores y PLC...<br /> <br />
can i have a complete circuit connection of this project where all the circuits in the step by step process are connected? i already made a simulation of this circuit but it happened that there is nothing on the display i just wanna ask why is that so... thanks
why is there a white led there in the middle?<br />
oh, that led!.. dont worry its not important at all...<br /> I just connected it in the same spot as the first display clock, so i can always know wich is the next digit, (the first or second display), its just a visual aid to so i wont loose track of where the next number will appear, but it doesnt affect or improves the sistem
hello to the creator of this digital combination lock i think that this project was great...just want to ask something from your first step...i am having a problem with the switch &quot;9&quot; ,why is it the number &quot;9&quot; switch is not working in me, it keeps displaying number &quot;8&quot;, so i want to ask if there is some problem with your schematic diagram from your first step, your fifth diode from the top. the one that is connected from the nineth switch connecting binary bit &quot;A&quot;.
hello to the creator of this digital combination lock i think that this project was great...just want to ask something from your first step...i am having a problem with the switch &quot;9&quot; ,why is it the number &quot;9&quot; switch is not working in me, it keeps displaying number &quot;8&quot;, so i want to ask if there is some problem with your schematic diagram from your first step, your fifth diode from the top. the one that is connected from the nineth switch connecting binary bit &quot;A&quot;.
ma chudayo tum <br>
Hola que tal veo que este proyecto lo hiciste hace tiempo, tengo algunas dudas, me estoy &quot;inspirando&quot; en tu circuito para hacer un proyecto de electronica, no nos dejan usar micro ni nada de eso puras compuertas y cosas basicas. <br><br>Me preguntaba si podrias darme mas info sobre el circuito, mi problema esta a la hora de querer hacerlo de 4 numeros la clave, no se como cambiar de memoria cada que pulso un boton... Tu lo haces con el J-K pero como seria para 4 ? <br><br>Gracias y espero que puedas responder
Nice <br>The LS7220 or LS7222 chips are designed so that you can do the majority of this, minus the displays. I remember when I did this project from scratch. I designed it very similarily. <br>=)
yeah, i think that the best part of building something like this {designing everything from scratch} is the excitment of the adventure... having your first design problems, having to do research to solve them, {and probably go nuts for a few days till you get it}... <br>as i mentioned around the begining, i was trying to use the most basic logic posible, you know, it was when i just completed my first digital electronics course, and most of the IC you could normally order online werent avaliable around here, {thank to Steren, now we got lots of IC and cool stuff cheaper and faster than before}.. <br> <br>anyway, i built it so much time ago... and now i perfectly know how to use uControllers, {PICs}.. so, everything could be controlled from a single chip... <br>but it was a nice first project... <br> <br>now i look back at this, and feel a little bit homesick, but proud to have learned so much since then, and willing to keep learning! <br> <br>ps. thanks for the IC number :D
It may or may not be interesting, but use of a CD74hc4511 chip will free up a lot of board space (it's a all in one 7-segment to bcd decoder with flip flop and latch).&nbsp; That way you can support up to 7 displays with a chip per segment and a single 8-3 multiplexer.&nbsp; That can easily go from 7 to 15 with an additional multiplexer and only need 4 lines for data (always), and 3 lines for addressing (1 extra per new multiplexer).&nbsp; <br /> <br /> Nice project, this was very similar to the Digital Systems final Project I had to do in college.<br />
&nbsp;Impressive. I always wanted to make a clock out of low level logic like this. Just seems like a lot of work. It is amazing how much easier/cheaper using a micro controller for something like this.
&nbsp;indeed, arduino + keypad, + seven segment displays and some code...<br /> thats actually my next project, for a weather station.
Quite an impressive job, both the project and the write up.&nbsp; The only project I ever attempted like that on a breadboard, was a digital clock, which kept terrible time.&nbsp; It took months to wire up, and figure out what went wrong.&nbsp; I've since switched to microcontrollers.&nbsp; So much easier to debug code, and you can take it anywhere to work on.<br /> <br /> Might also look into making PCB at home.&nbsp; It's not very expensive, and pretty easy with a laser printer.&nbsp; Although, got a hunch your project would still take sometime to layout, and drilling so many holes...<br /> <br /> Really nice work, though don't imagine very many people will build this, maybe a class project.<br />
thanks, and yeah, i used this as my final proyect in school, you see im currently a 11th grade student here in Acu&ntilde;a, Mexico(Cbtis 54! arriba chivos bravos!)...<br /> so I still dont know how to use microcontrollers (will be seen on 12th), so I used everything i knew so far. <br /> And yeah, microcontroller look really cool, so cant wait to try them!! <br /> which one will be the best&nbsp;for a beginner like me?, PIC, AUDRINO, AVR?...
Saludos desde Monterrey, yo soy de Sabinas y estudie en el CBTIS&nbsp;20 hace ya rato. Es bueno ver gente de la regi&oacute;n entrando a estas cosas<br />
claro que si amigo, yo tambien estaba arto de ver muy pocos trabajos echos por compa&ntilde;eros mexicanos, y pense &quot;pues no keda otra mas que poner manos a la obra&quot; y asi fue coomo empeze, ultimamente he estado algo ocupado por eso no he podido seguir pero pronto continuare con los proyectos...
i would suggest Cypress Semiconductor PSoC -3&nbsp;&nbsp; (programmable system on chip)&nbsp; with a little practice writing C you can implement really complex systems with very few external components.&nbsp; they take an FPGA and various analog circuits and wrap them up with a microprocessor on one chip.<br />
&nbsp;I agree with Luminous. Arduino is really great for beginners. If you can make a project like this, then you will have no trouble with it at all. Great Instructible.
For a beginner, I would definitely suggest Arduino. You just plug it into the computer and go. No need for any fancy programmers or any of that. Just a USB port and a cable.<br />
Great job! Not trying to flame it or anything, but it looks kinda like a bomb lol<br />
<p>This is really good! It's a lot of info to put together.<br /> <br /> I'm starting a Digital Electronics course in Feb. so I'd love to try build this.</p>

About This Instructable




More by Nino123:Digital Combination Lock! 
Add instructable to: