elektronika kifo
hrvatski jezik


Devices known as electrical key-lock can be found in many versions, but I will demonstrate you another interesting workaround of that device. Specificity of that device is a new way to read more keys using only one input of microcontroller. As you can see I used an analog to digital conversation and with that method I can precise detect which key is pressed. This way of detecting keys can be implemented only with microcontrollers who have an internal A/D converter, and we will use PIC12F675, because we don’t need many ports for reading state of keys.

početna stranica
send e-mail
hex file

How it works

Press four keys in specific order, and relay will turn on for about to 5 seconds and that is it. But first you must memorize your code following this way: press and hold button (button on pin 3), so long until Led goes ON. Now, when Led is ON, you must type your secret code. When you do that, your code is memorized in eeprom of PIC12F675, and you can only turn ON relay using this code. If you type false code 10 times, you will turn ON “alarm” relay. It is simple for everyone.

Recognizing keys with a/d converter

As you can see keyboard is made from a series of resistors and keys. On keyboard are connected only 3 wires, +5V, minus and a line that goes to pin 7 of microcontroller. Resistors are connected in series and on every junction there is a different value of voltage. When we press any key on keyboard, we produce a specific voltage from the specific key on pin 7 of microcontrollers. Pin 7 on PIC12F675 is defined as input and it is internally connected to an A/D converter module. PIC12F675 has a 10 bit A/D converter and possible values of conversion range from 0-1023. So, if we have 12 keys, range between them is 85. Following that calculation “key 0” ranges from 0-85, “key1” from 86-170, “key2” from 171-256 ….

I think that is possible to connect more then 12 keys on that way with good authentication of each key.

Schematic Keylock

More information about KeyLock you can find in magazine "Svijet elektronike", nr. 51, April/May 2005 .
Author: Ivica Novakovic

You can download the circuit and PCB here:

Keylock sch & pcb - Protel-99 SE.
Keylock.pdf - circuit in pdf format

circuit board

You can download the hex file here: Keylock hex

Kodna brava


Since I have noticed that there is a problem with programming these microcontrollers you should read the short how-to for programming PIC12F629/675 microcontrollers.

If you have any difficulty in making this device, feel free to mail me.



Elektronika Kifo

If you use the software, hardware or informations from these pages, you do it at your own risk. All projects are copyrighted and you shall not in any manner distribute, use or make copies of, or otherwise duplicate any materials and projects contained on the Website, without permission of author

send e-mail