• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Contact | Calculators-online
You are here: Home / Arduino Projects / Password Security Lock Circuit Using 4×4 Keypad and Arduino

Password Security Lock Circuit Using 4×4 Keypad and Arduino

Last Updated on December 5, 2024 by Swagatam 5 Comments

In this post I will show how 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:

P 20160904 142810 2

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.  Car Reverse Parking Sensor Circuit with Alarm
  • 2.  Vehicle Speed Detector Circuit for Traffic Police
  • 3.  Introduction to RGB Colour sensor TCS3200
  • 4.  Raspberry Pi Explained
  • 5.  How to Make a RFID based Attendance System
  • 6.  Microcontroller Basics Explored

About Swagatam

I am an electronics engineer with over 15 years of hands-on experience. I am passionate about inventing, designing electronic circuits and PCBs, and helping hobbyists bring their projects to life. That is why I founded homemade-circuits.com, a website where I share innovative circuit ideas and tutorials. Have a circuit related question? Leave a comment.... I guarantee a reply!

Previous Post: « Sunrise Sunset Simulator LED Circuit
Next Post: Bluetooth Motor Controller Circuit »

Reader Interactions

Comments

  1. Satish says

    May 25, 2017 at 12:23 am

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

    Reply
    • Swagatam says

      May 25, 2017 at 10:26 am

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

      Reply
  2. Manas Mallick says

    September 11, 2016 at 5:02 am

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

    Reply
    • Swagatam says

      September 11, 2016 at 1:49 pm

      Dear Manas, you can refer to the following link

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

      Reply
  3. Davis Kakumba says

    September 7, 2016 at 8:13 am

    so huge , i like that its massive

    Reply

Need Help? Please Leave a Comment! We value your input—Kindly keep it relevant to the above topic! Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Subscribe to New Circuit Ideas

Categories

  • Arduino Projects (87)
  • Audio and Amplifier Projects (132)
  • Automation Projects (17)
  • Automobile Electronics (101)
  • Battery Charger Circuits (82)
  • Datasheets and Components (102)
  • Electronics Theory (143)
  • Free Energy (37)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (19)
  • Health related Projects (25)
  • Home Electrical Circuits (12)
  • Indicator Circuits (14)
  • Inverter Circuits (87)
  • Lamps and Lights (142)
  • Meters and Testers (69)
  • Mini Projects (46)
  • Motor Controller (64)
  • Oscillator Circuits (27)
  • Pets and Pests (15)
  • Power Supply Circuits (108)
  • Remote Control Circuits (50)
  • Security and Alarm (64)
  • Sensors and Detectors (100)
  • Solar Controller Circuits (59)
  • Temperature Controllers (42)
  • Timer and Delay Relay (49)
  • Transmitter Circuits (29)
  • Voltage Control and Protection (37)
  • Water Controller (36)

Calculators

  • 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
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator
  • Filter Capacitor Calculator
  • Buck Converter Calculator
  • Boost Converter Calculator
  • Solar Panel, Inverter, Battery Calculator
  • Wire Current Calculator
  • SMPS Transformer Calculator
  • IC SG3525, SG3524 Calculator
  • Inverter LC Filter Calculator

People Also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Recent Comments

  • Swagatam on Simple Delay Timer Circuits Explained
  • Swagatam on The Role of Inductor Coil in SMPS
  • Swagatam on 7 Modified Sine Wave Inverter Circuits Explored – 100W to 3kVA
  • Swagatam on 7 Modified Sine Wave Inverter Circuits Explored – 100W to 3kVA
  • Victor on 7 Modified Sine Wave Inverter Circuits Explored – 100W to 3kVA

Company

  • Privacy Policy
  • Cookie Policy
  • About Me
  • Contact
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Quora
  • Stack Exchange
  • Linkedin
  • © 2025 · Swagatam Innovations