• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Get free circuit help 24/7

  • Circuits for Beginners
  • Basic Circuits
  • Hobby Projects
  • Transistor Circuits

New-Projects | Privacy Policy | About us | Contact | Disclaimer | Copyright

Home » Arduino Engineering Projects » Password Security Lock Circuit Using 4×4 Keypad and Arduino

Password Security Lock Circuit Using 4×4 Keypad and Arduino

Last Updated on January 31, 2019 by Swagatam

In this post we are going to construct a password security lock circuit, which can be accessed by a 6-digit password. To be more precise it is alpha numeric password.

 

Hardware for this Project

We are going to utilize 4x4 keypad, which consists of 0 to 9 decimal values, two special character ‘#’ and ‘*’ and A to D alphabets. The combination of these characters can be used as password.

The Arduino is the brain of the system, a relay is interfaced with Arduino to activate and deactivate, when the correct password is commanded. Two indicator LED is utilized here to indicate status of the lock system.

If you are not familiar with 4x4 keypad, please refer to my earlier article, which comprehensively discussed basics of 4x4 matrix keypad

The proposed project has pretty minimalistic hardware design. It just consist a keypad, relay, arduino and couple of LEDs, even a noob in arduino can accomplish it with ease.

The only part which is slightly difficult in this project is the coding, need not to worry the code is given in this project. The program should be written in such a way that, it is fool proof and no hijacker can hack the system.

But, be careful if you expose the hardware or the hardware of this project is easily accessible, the relay can be hacked with ease. So keep this project in well protected chassis.

How it Works

Note: A current limiting resistor 4.7K must be connected to base of the transistor, which is not shown in the diagram.

Now let’s see how this Arduino password security lock circuit functions, please read the instruction given below carefully, in order to operate the circuit.

Circuit Diagram

Arduino Password Security Lock Circuit Using 4x4 Keypad

Here are the two illustrations how to interface keyboard and Arduino:

Arduino Password Security Lock Test Results

• When the circuit is powered on, it asks for password, you can see on the serial monitor (serial monitor is not mandatory but, can be used for testing purpose).

• Enter the password which you entered in the program before compiling it.

• While you press the keys, green LED blinks for one tenth of a second, indicating that some key is pressed by the user.

• Once you entered the 6-digit password, press ‘D’ in the keypad which acts as ‘Enter’. If your password is correct, the relay gets activated, green LED turns ON.

• To deactivate the relay, press ‘C’ in the keypad. When, this is done, green LED turns OFF and relay gets deactivated. No other key can deactivate the relay.

• If the password enter by the user is incorrect, then red LED lights up and the user have to wait 30 second to enter the next attempt. When the 30 second is over, the red LED turns OFF, informing the user that, the system ready to get input from the user.

• When the relay is deactivated after successful activation, in order to activate the relay again, the user needs to enter the password again and press ‘D’.

Here is a special case:

• When the correct password is entered, the relay gets activated and after the successful deactivation, when the user hits any one wrong keystroke (not whole password), the program recognize as incorrect password and the user need to wait another 30 second. If this was a hijacker it will delay the number of attempt done by the hijacker.

• When correct keystroke is pressed on the first attempt, only then it allows to enter next key. This is only for first keystroke only and not for all the successive keystrokes.

• The motto of the above explained concept is to delay the number of attempts done by the hijacker.

Program Code:

//---------------------------------Program Developed by R.Girish--------------------------//
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char pass[] = "123ABC"; // 6 digit password only (no less or no more)
int OP=10;
int green=12;
int red=11;
char key1;
char key2;
char key3;
char key4;
char key5;
char key6;
char dumpkey;
char keyOK;
char ok[]="D";
char offkey;
char off[]="C";
int z;
char keys[ROWS][COLS] =
{
{'D','#','0','*'},
{'C','9','8','7'},
{'B','6','5','4'},
{'A','3','2','1'}
};
byte rowPins[ROWS] = {6,7,8,9};  //connect to the row pinouts of the keypad
byte colPins[COLS] = {2,3,4,5}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
Serial.begin(9600);
pinMode(OP,OUTPUT);
pinMode(green,OUTPUT);
pinMode(red,OUTPUT);
digitalWrite(OP,LOW);
}
void loop()
{
top:
Serial.println("");
Serial.println("[Press D = Enter]");
Serial.print("Enter the password: ");
key1=keypad.waitForKey();
if(key1 == pass[0])
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
{
z=1;
Serial.print("*");
goto A;

}
}
else
{
goto dump;
}
A:
key2=keypad.waitForKey();
if(key2 == pass[1])
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
{
z=2;
Serial.print("*");
goto B;
}
}
else
{
goto dump;
}
B:
key3=keypad.waitForKey();
if(key3 == pass[2])
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
{
z=3;
Serial.print("*");
goto C;
}
}
else
{
goto dump;
}
C:
key4=keypad.waitForKey();
if(key4 == pass[3])
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
{
z=4;
Serial.print("*");
goto D;
}
}
else
{
goto dump;
}
D:
key5=keypad.waitForKey();
if(key5 == pass[4])
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
{
z=5;
Serial.print("*");
goto E;
}
}
else
{
goto dump;
}
E:
key6=keypad.waitForKey();
if(key6 == pass[5])
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
{
z=6;
Serial.print("*");
goto ok;
}
}
else
{
goto dump;
}
ok:
keyOK=keypad.waitForKey();
if(keyOK == ok[0])
{
digitalWrite(OP,HIGH);
digitalWrite(green,HIGH);
Serial.println("");
Serial.println("Relay Activated, Press 'C' to Deactivate.n");
}
else
{
Serial.println("");
Serial.println("Press 'D' to Enter");
goto ok;
}
off:
offkey=keypad.waitForKey();
if(offkey==off[0])
{
digitalWrite(OP,LOW);
digitalWrite(green,LOW);
Serial.println("Relay Deactivated.n");
goto top;
}
else
{
Serial.println("Press 'C' to Deactivaten");
goto off;
}
dump:
if(z==0)
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
goto error;
}
if(z==1)
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
goto error;
}
if(z==2)
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
goto error;
}
if(z==3)
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
goto error;
}
if(z==4)
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
goto error;
}
if(z==5)
{
digitalWrite(green,HIGH);
delay(100);
digitalWrite(green,LOW);
Serial.print("*");
dumpkey=keypad.waitForKey();
Serial.print("*");
goto error;
}
error:
Serial.println("");
Serial.print("Wrong password, Wait for 30 seconds.");
digitalWrite(red,HIGH);
delay(10000);
delay(10000);
delay(10000);
digitalWrite(red,LOW);
goto top;
}
//---------------------------------Program Developed by R.Girish--------------------------//

NOTE: To set password: char pass[] = "123ABC"; // 6 digit password only (no less or no more)
Change “123ABC” with your own password, inside quotation mark.

Make sure the password set in the program is 6-digit ONLY, no less or no more but, exactly 6-digit. Otherwise the program won’t function correctly.

If you have any further doubts regarding the explained password security lock circuit, please feel free to post them through your comments

You'll also like:

  • 1.  Make this Buck Converter Using Arduino
  • 2.  Converting Analogue to Digital (Analogue Read Serial) – Arduino Basics
  • 3.  Automatic Irrigation Circuit using Arduino
  • 4.  High Current Motor Control Circuit using Arduino
  • 5.  Making a Single Channel Oscilloscope using Arduino
  • 6.  2.4 GHz 10 Channel Remote Control Switch

About Swagatam

I am an electronic engineer (dipIETE ), hobbyist, inventor, schematic/PCB designer, manufacturer. I am also the founder of the website: https://www.homemade-circuits.com/, where I love sharing my innovative circuit ideas and tutorials.
If you have any circuit related query, you may interact through comments, I'll be most happy to help!

Subscribe2


 

Reader Interactions

Comments

  1. Davis Kakumba says

    so huge , i like that its massive

  2. Manas Mallick says

    Dear Swagatam,I am interested to learn
    Arduino.But I am novice so please post some links whether I can learn ABCD of
    Arduino.

    • Swagatam says

      Dear Manas, you can refer to the following link

      https://www.arduino.cc/en/Tutorial/HomePage

  3. Satish says

    sir can i use this circuit for car ignition if not kindly suggest a circuit so its helpful thank you sir

    • Swagatam says

      Satish, yes you an use this circuit for car ignition locking or for any relevant locking application

Primary Sidebar

Categories

  • 3-Phase Power (15)
  • 324 IC Circuits (19)
  • 4017 IC Circuits (53)
  • 4060 IC Circuits (25)
  • 555 IC Circuits (98)
  • 741 IC Circuits (19)
  • Amplifiers (58)
  • Arduino Engineering Projects (82)
  • Audio Projects (94)
  • Battery Chargers (82)
  • Car and Motorcycle (94)
  • Datasheets (46)
  • Decorative Lighting (Diwali, Christmas) (33)
  • DIY LED Projects (89)
  • Electronic Components (97)
  • Electronic Devices and Circuit Theory (35)
  • Electronics Tutorial (109)
  • Fish Aquarium (5)
  • Free Energy (35)
  • Fun Projects (11)
  • GSM Projects (9)
  • Health Related (18)
  • Heater Controllers (28)
  • Home Electrical Circuits (101)
  • How to Articles (20)
  • Incubator Related (6)
  • Industrial Electronics (28)
  • Infrared (IR) (40)
  • Inverter Circuits (98)
  • Laser Projects (12)
  • LM317/LM338 (21)
  • LM3915 IC (25)
  • Meters and Testers (62)
  • Mini Projects (172)
  • Motor Controller (66)
  • MPPT (7)
  • Oscillator Circuits (24)
  • PIR (Passive Infrared) (8)
  • Power Electronics (33)
  • Power Supply Circuits (74)
  • Radio Circuits (9)
  • Remote Control (47)
  • Security and Alarm (61)
  • Sensors and Detectors (116)
  • SG3525 IC (5)
  • Simple Circuits (75)
  • SMPS (29)
  • Solar Controllers (61)
  • Timer and Delay Relay (54)
  • TL494 IC (5)
  • Transformerless Power Supply (8)
  • Transmitter Circuits (40)
  • Ultrasonic Projects (14)
  • Water Level Controller (45)

Circuit Calculators

  • AWG to Millimeter Converter
  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator

Facebook
Twitter
YouTube
Instagram
My Facebook-Page
Quora

© 2022 · Swagatam Innovations

We use cookies on our website to give you the best experience.
Cookie settingsAccept All
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Please visit the Privacy Policy Page for more info.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT