Make Your Own Security Code Lock

efy tested

The circuit described here is an electronic combination Security Code Lock. It opens only when you press four keys in the correct sequence (referred to as a code) out of a total of eight keys installed at your entrance door. If you press the wrong key sequence, the circuit resets, and the lock will not open. The author’s prototype is shown in Fig. 1.

Security Code Lock Circuit on breadboard
Fig. 1: Prototype of the lock tested on a breadboard

Security Code Lock – Circuit and Working

The circuit diagram of the security code lock is shown in Fig. 2. The circuit consists of step-down transformer X1, bridge rectifier BR1, 12V voltage regulator LM7812 (IC1), dual-D flip-flop ICs 4013 (IC2 and IC3), rectifier diode 1N4007 (D1), PNP transistor BC557 (T1), npn transistor 2N2219 (T2), 12V single changeover relay RL1, and a few other components.

Security Code Lock Circuit diagram
Fig. 2: Circuit diagram

This project operates with 12V DC which is derived from the 230V AC primary to 15V, 500mA secondary step-down transformer X1. The 230V AC mains is connected to the primary of X1 via CON1 in the circuit. The secondary of X1 is 15V AC, which is connected to bridge rectifier BR1 for rectification and filtered by capacitor C1.

The rectified and filtered voltage is then supplied to regulator IC LM7812 (IC1) to regulate it to 12V for enabling the circuit. The glowing LED1 indicates that 12V is available to enable the circuit.

The heart of this code lock circuit is the CD4013 dual-D flip-flop IC. The clock pins (pins 3 and 11 of IC2 and IC3) of its four flip-flops are connected to CO1, CO2, CO3, and CO4 points. The correct code sequence for energizing relay RL1 is achieved by clocking in the correct sequence, which is the code of the lock. In this case, the code is 8, 2, 6, and 5 (8265).

Therefore, you need to press switches S8, S2, S6, and S5 in the correct sequence to open the door. The remaining four switches (S1, S3, S4, and S7) are connected to the CO5 reset point, which resets all the flip-flops. By momentarily pressing switches S8, S2, S6, and S5, the clock input pin goes high and alters the state of the flip-flops.

The Q output pin of each flip-flop is wired to the D input pin of the next flip-flop, while the D pin (pin 5) of the first flip-flop (IC2) is grounded.

The lock code can be changed by altering the connections to the points CO1, CO2, CO3, and CO4. For example, if you want to set the code as 1756, you should connect the respective switch S1 to CO1, S7 to CO2, S5 to CO3, and S6 to CO4, and connect the rest of the switches, such as S2, S3, S4, and S8, to the reset point CO5.

However, in this project, the set code is 8265. Therefore, the respective switches S8, S2, S6, and S5 are connected to CO1 through CO4, and the remaining switches (S1, S3, S4, S7) are connected to reset point CO5, as shown in the schematic (Fig. 2).

If the correct clocking sequence is followed, a low level (GND) appears at the Q2 output (pin 13) of IC3, which energizes the relay through relay driver transistors T1 and T2. As a result, the solenoid activates and the lock opens. The reset keys are connected to the set pins 6 through 8 of IC2 and IC3. The power-on-reset capacitor C2 is used to stabilize the pulses during the power-on of the circuit.

Parts List
IC1 – LM7812, 5V voltage regulator
IC2 (IC2A-IC2C),
IC3 (IC3A-IC3C) – 4013 D-flip-flop
D1 – 1N4007 rectifier diode
LED1 – 5mm LED
T1 – BC557 pnp transsitor
T2 – 2N2219 npn transistor
Resistors (all 1/4-watt, ±5% carbon):
R1, R7 – 1-kilo-ohm
R2-R6 – 1-mega-ohm
C1 – 1000μF, 35V electrolytic
C2 – 100nF ceramic disk
CON1-CON3 – 2-pin connector
SV – 12V solenoid valve
RL1 – 12V, 1C/O (SPDT) relay
X1 – 230V AC primary to 15V, 500mA secondary transformer

Construction and Testing

An actual-size, single-side PCB layout for the lock is shown in Fig. 3 and its component layout is shown in Fig. 4. After assembling the circuit on PCB, enclose it in a suitable box. Fix LED1 and CON1 on the front side of the box, and fix connectors CON2 and CON3 on the rear side of the box. Use CON2 for connecting the power supply of the solenoid valve and CON3 for connecting the solenoid valve.

Actual-size PCB layout of the Security Code Lock circuit
Actual-size PCB layout of the circuit
Component side of the Security Code Lock PCB
Fig. 4: Component side of the PCB


First, create a 4×4 keypad matrix. Connect the respective switches (based on the code lock) to CO1 through CO4 and connect the remaining switches to the reset point CO5. Now, install this keypad at the entrance door and connect the solenoid valve to the circuit. Your circuit is now ready to use.

You can also install this simple code lock circuit in your car so that it starts only when the correct code sequence is entered via the keypad. The code lock design can also be used in various other applications.

Bonus. You can watch the video of the tutorial of this DIY circuit idea at

Download PCB and Component Layout PDFs: click here

S.C. Dwivedi is an electronics enthusiast and circuit designer at EFY

Source link

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.