Peter's electronic projects

Electronic door codelock with PIC

designed by Peter JAKAB

NOTE for beginners: PICs are general purpose microcontrollers which have to be programmed before you can use them in the actual circuit! Check out this link to learn more.

description

This is my electronic codelock to use with an outdoor gate. The lock itself is implemented in software. It operates a relay (for example to open a door) for a few seconds if someone enters the valid code. The secret code can be changed any time after entering the current code. Note that in this application it's not necessary to make an exact clock frequency with crystal (as seen on the schematic diagram), you can also use an RC type oscillator or other crystals. By a small modification in the sources you can eliminate the LS139 multiplexer (use one output pin for each row). This circuit was in fact designed to be used as a general test board.

software

I finally cleaned up the source code for the lock, cutting out all the unneeded serial line handlers. The result of this work is the downloadable source code. The old, compiled operating code for this lock is still available if you don't want to bother much: 16F84 HEX file. You can of course decide to adapt and compile the source to other PIC controllers.

operation

The keyboard, which is organized into a matrix looks like this:

  COL0 COL1 COL2 COL3
ROW0 1 2 3 A
ROW1 4 5 6 B
ROW2 7 8 9 C
ROW3 * 0 # D

Column 3 is not necessary in this application. # is used as 'enter' after you type in the valid code. The initial code is 3345 after power-on. You could activate the output with typing in:

3 3 4 5 #

* is used to change the code. Type in the actual code then press *, then type in the new code. Eg:

3 3 4 5 * 1 9 9 8

will change the code to 1998. The code changes immediately after typing the 4th digit. If one were to power off and then on, the code would revert to 3 3 4 5. Adding a small 3.6V accumulator to the design could preserve the memory during power failure, or modifying the source it would also be possible to write the code in the internal EEPROM of the microcontroller (if it has one).

Schematic diagram