Summary of Single button code entry for a digital lock using PIC16F628A
The Button Code system converts a single button into a secure keypad using a PIC16F628A microcontroller. Users input a 4-digit code via button taps, triggering visual feedback through LED flashes on the same wires. The system activates a Form-C relay to control devices like garage doors or alarms in either timed or toggle modes. Configuration is handled via a program jumper and menu options accessible while in program mode, allowing users to change codes, activation times, and operation styles without external tools.Parts used in the Button Code System:
- PIC 16f628A microcontroller
- Single button switch
- Form-C relay (Normally Open and Normally Closed contacts)
- LED for visual feedback
- Program jumper
- Non-volatile flash memory
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.
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
Quick Solutions to Questions related to Button Code System:
-
How does the user enter a code?
Tap the button once for each number in the 4-digit sequence, waiting for a confirmation flash between digits. -
Can the button be placed in public areas?
Yes, because there are many combinations to prevent guessers from activating the system. -
What happens if the entered code is wrong?
A slow flash will be displayed on the LED to indicate an incorrect entry. -
How do you switch from running mode to program mode?
Insert the program jumper when power is applied to the system. -
Does the system retain settings without power?
Yes, the code, activation time, and operational mode are stored in non-volatile flash memory. -
How can you change the activation time?
Tap the button once for each second desired in the program menu option. -
What is the difference between timed and toggle modes?
In timed mode the relay deactivates after a set time, while toggle mode changes the relay state with every correct code entry. -
How many wires are needed to run to the button location?
Only 2 wires are needed as the controller provides visual feedback over the same terminals used for input.
Related projects
DHT11 Low Cost Humidity Sensor using PIC16F628A with Proteus Simulation
IntroductionThis microcontroller project demonstrates how to interface a low-cost DHT11 temperature and humidity sensor with a PIC16F628A using a Proteus simulation environment.The...
LCD & Display Projects · PIC16F628AFrequency Counter by PIC16F628
In this project we are building a basic and low cost frequency counter circuit . It can measure from 16Hz to 100Hz...
Games, Toys & Calculators · PIC16F628ATIC TAC TOE game using PIC16F628
This project is not to introduce Tic Tac Toe. Everyone knows this game. It's to introduce two features. Bi-coloured LEDs, microcontrollers and...
Home Automation & SecurityVoice Activated Power Sockets (Home Automation)
Yet another voice controlled home automation system! As shown in the picture, the system can control any electrical appliance, by turning ON...
Home Automation & SecurityHome Security System with GSM Using 8051 Microcontroller
Security is a big challenge everywhere because thefts are increasing day by day owing to the unsafe and insecure security systems in...
Home Automation & SecurityHome Automation and Security System using Microcontroller ATMEGA8 with Arduino Programming
Home automation and security systems have become very popular these days, today industrial automation techniques are widely adopted by luxurious homes and...
