Single button code entry for a digital lock using PIC16F628A

The Button Code is a system that allows a single button to act as a keypad. The user enters a 4 digit code into the system using button taps. The button can be placed where the public can access it since like a keypad there are many combinations to keep guessers from activation the system. When the correct code is entered a form-C relay is activated (Normally Open and Normally Closed relay contacts). When activated it can either activate for a programmed time or simply toggle the output whenever the correct code is entered.

button

This simple circuit allow for simple control of things such as:

  • Garage Door Openers – Pulse the door open button for a second to operate.
  • Lighting – Toggle to turn on, toggle to turn off.
  • Door Access – Pulse the door lock for 3 or 4 seconds.
  • Simple Security System – Toggle  alarm power on or off.

To purchase this controller please have a look at our online store.

If you prefer reading a printed manual have a look at the manual here (pdf).

Video

Overview

The heart of the button code project is a PIC 16f628A microcontroller (PDF). This microcontroller monitors user input using a single button that is connected to the button terminals. The controller provides visual feedback to the user over the same button terminals, this means that only 2 wires are needed to be run to the button location. A relay is controlled by the system, it is only activated when the correct code has been entered.

Modes

The button code system has two operating modes. One is normal running mode where it is waiting for a code to be entered and reacts as programmed when the correct code is entered. The second running mode is program mode, this mode is used to configure the system to operate is as you desire.

Changing Running Modes

There is a program jumper that is used to change the running mode. When the jumper is out the mode is the normal running mode, when the jumper is in the system is in program mode.

Please note that the state of the jumper is only checked when power is applied. This means that if the system is in program mode and the jumper is removed, the mode will not change until power is removed and re-applied.

Normal Running Mode

In normal running mode the system is waiting for a code to be entered and reacts as programmed when the correct code is entered. To enter a code tap the button once for each number in code digit, wait for a confirmation flash, then proceed with the next digit in the 4 digit sequence.

For example if the code to be entered is 1, 2, 3, 4 you would do the following.
•    Press the button 1 time
•    Wait for a confirmation flash from the LED
•    Press the button 2 times
•    Wait for a confirmation flash from the LED
•    Press the button 3 times
•    Wait for a confirmation flash from the LED
•    Press the button 4 times

After the 4 digit code has been entered the system will operate as programmed. If the code is wrong a slow flash will be displayed on the LED.

Program Mode

There are three program menu options, to change between the menu options press and hold the button for at least 3 seconds. When the button is released you will be in the next menu option. The LED will flash to let you know what menu option you are in. For example Flash, Flash, pause, Flash, Flash, pause… means that the system is in menu 2.

Program Mode Menu Options

1) Code Change: Used to change the 4 digit system code. Tap in the new code that is desired just as you would when in normal running mode. The system will give you a fast flash confirmation when the new code has been saved.

2) Activation Time Change: Used to change the activation time desired. Tap the button once for each second desired. For example if you would like a 10 second activation time just tap the button 10 times. The system will give you a fast flash confirmation when the new activation time has been saved.

3) Operation Mode Change: Used to change the operation style.

  • The first mode is a timed mode, in this mode the relay is activated when the correct code is entered and de-activates after the activation time is up.
  • The second mode is a toggle mode, in this mode the relay state is changed whenever a correct code has been entered. For example if the relay is de-activated it will activate when a correct code is entered and if the relay is activated when a correct code is entered is will de-activate.

To change the mode, press the button once for the first mode and twice for the second mode.

Code

The system is continuously monitoring the state of the button since that is the only user input. The result of button presses will vary greatly depending on the state of the system. The actual system code, the activation time and the operational mode are stored in non-volatile flash memory so that is remains without power.

 

For more detail: Single button code entry for a digital lock using PIC16F628A

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter