Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science

27 December 2009
Author: Giorgos Lazaridis
Simple Keycode Lock

The circuit on a breadboard for test. This circuit has the CD4072 Chip included and can be used with touch keypad as well.

Imagine that you sit on your PC desk, you pull the keyboard, the mouse is near by, you click the button and the computer boots. Now imagine the same scene, but instead of pushing just a button, you enter the security code! That was one of my imaginations when i was a kid. Nowadays, i could make a more complex systems, with security code, LCD display and hardware key, but i decided to make a more simple yet secure circuit for the other 'kids' that want to boot with more than just a cold pushbutton.

Here is a video from the circuit in operation!

The Circuit

There are more simple but less secure circuits. This circuit has a 4-digit security code that is hardware selectable. It can have as many 'wrong' digits as you like, but up to 4 'correct' digits. Also, one digit cannot be more than once in the security code. Suppose for example that you choose to have 10 digit keypad with numbers from 0 to 9. One code could be the number 5293, or the 7520, but the code 4429 is wrong! The digit '4' is more than once in the code and that cannot happen.

The schematic digram is as follows:

Each 'correct' key press will SET a flip-flop. When the 4th flip-flop is SET, the relay will be armed through the PNP transistor. Whenever a 'wrong' button is pressed, all 4 flip-flops will be RESET and the code must be entered again from the beginning. Also, if the code must be entered in the correct order. If for example the code is 1234 and instead you press 1 and then 3, the flip-flops will also RESET.

To be more secure, the keypad should be on another remote PCB

The keypad could be normal pushbuttons

The keypad can have as many keys as you like. From the circuit you have 5 inputs, the D1, D2, D3, D4 and the ERR. The 4 D inputs are the 'correct' buttons. Each one must go to one and only key! For example, someone could connect the D1 to key number 4, the D2 to key number 2, the D3 to key number 9 and D4 to key number 5. The code to open the lock would be '4295'.

All the other buttons that will reset the circuit must be connected to the 'ERR' input. So if the keypad had 10 keys and the code was '4295' the keys 1,3,4,6,7,8 and 0 must be connected to the ERR input.

Here is an example of a keypad connection. A ribbon-cable is used to interface the keypad to the PCB. The four wires that correspond to the 4 buttons of the code are separately connected to the 4 D inputs. ll other wires are connected to the ERR input.

The keys can be a push-button with one normal-open contact, connected to the positive (VDD) of the circuit. Also, because i use CMOS, the keys could be touch-plates on the PCB itself. Look at the following PCB layout:

The circuit is designed to operate at any voltage between 5 and 15 volts. The only thing that needs to be changed is the relay. The one that i use is a 5V DPDT, but you can use whatever relay you like.

A nice print-out with some kind of artwork and holes that correspond to the keypad PCB-keys, can mask the keypad and make it more elegance

Bill Of Materials
 Resistors R1-5 Resistor 47 KOhm 1/4 Watt 5% Carbon Film R6 Resistor 4.7 KOhm 1/4 Watt 5% Carbon Film Transistors Q1 2N2907 General purpose amplifier and switching transistor ICs IC1 CD 4013 Dual D-Type Flip-Flop IC2 CD 4013 Dual D-Type Flip-Flop IC3 CD 4081 Quad 2-input AND buffered B series Gate IC4 CD 4072 Dual 4-input OR Gate Misc RELAY Relay DSDP miniature 5V relay

A more simple circuit

This circuit does not have the 4072 chip. It has the same functionality, it is simpler, but it cannot be used with touch keypads.

If you will use normal push-buttons for the keypad, i suggest you use the following circuit instead. This is exactly the same circuit as the previous one, with the only difference on the reset. It does NOT use the 4072 CMOS for gathering the reset signals. Instead, it uses diodes connected as OR gates. It has the same operation as the previous one, but it is not recommended to be used with a touch keypad! Only with pushbuttons. This circuit is significantly simpler and equally secure to the previous one. It needs a smaller PCB an one chip less.

Here is the schematic:

Bill Of Materials
 Resistors R1-5 Resistor 47 KOhm 1/4 Watt 5% Carbon Film R6 Resistor 4.7 KOhm 1/4 Watt 5% Carbon Film R7 Resistor 22 KOhm 1/4 Watt 5% Carbon Film Diodes D1-4 1N4148 Switching Diode Transistors Q1 2N2907 General purpose amplifier and switching transistor ICs IC1 CD 4013 Dual D-Type Flip-Flop IC2 CD 4013 Dual D-Type Flip-Flop IC3 CD 4081 Quad 2-input AND buffered B series Gate Misc RELAY Relay DSDP miniature 5V relay

Relative pages
• Basic transistor circuits
• Learn about the most popular PC Cooling methods
• 4000 series IC pinouts
• Learn how to interface ICs