Home > Ideas > Security – Safety Project Ideas > Password Based Door Lock System Using Arduino SIMULINO UNO

Password Based Door Lock System Using Arduino SIMULINO UNO

Summary of Password Based Door Lock System Using Arduino SIMULINO UNO


Security presents the primary challenge in today's modern society. Anyone can enter your personal residence at any moment in order to steal your belongings. In order to keep your home safe from burglars, you must ensure it is secure. A motor is installed on the door in this project to ensure that the door opens only if the password is correct. This project will help you understand the concept behind a relay. Relay functions as a mechanical switch for transferring very high voltage with control from a 3 or 5 volt signal using an npn transistor. Follow the circuit diagram to connect your hardware and then upload the hex file from the provided code to the Arduino Uno board. Password Based Door Lock System Using Arduino SIMULINO UNO (Code) #include #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(9, 8, 7, 6, 5, 4); const byte ROWS = 4; //four rows const byte COLS = 4; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { {'7','8','9','/'}, {'4','5','6','*'}, {'1','2','3','-'}, {'C','0','=','+'} }; byte rowPins[ROWS] = {3, 2, 19, 18}; //connect to the row pinouts of the keypad byte colPins[COLS] = {17, 16, 15, 14}; //connect to the column pinouts of the keypad //initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); const int LED_RED=10; //Red LED const int LED_GREEN=11; //Green LED const int RELAY=12; //Lock Relay or motor char keycount=0; char code[4]; //Hold pressed keys //================================================================= // SETUP //================================================================= void setup(){ pinMode(LED_RED,OUTPUT); pinMode(LED_GREEN,OUTPUT); pinMode(RELAY,OUTPUT); // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("Password Access:"); lcd.setCursor(0,1); //Move coursor to second Line // Turn on the cursor lcd.cursor(); digitalWrite(LED_GREEN,HIGH); //Green LED Off digitalWrite(LED_RED,LOW); //Red LED On digitalWrite(RELAY,LOW); //Turn off Relay (Locked) } //================================================================= // LOOP //================================================================= void loop(){ char customKey = customKeypad.getKey(); if (customKey && (keycount<4) && (customKey !='=') && (customKey !='C')){ //lcd.print(customKey); //To display entered keys lcd.print('*'); //Do not display entered keys code[keycount]=customKey; keycount++; } if(customKey == 'C') //Cancel/Lock Key is pressed clear display and lock { Lock(); //Lock and clear display } if(customKey == '=') //Check Password and Unlock { if((code[0]=='1') && (code[1]=='2') && (code[2]=='3') && (code[3]=='4')) //Match the password { digitalWrite(LED_GREEN,LOW); //Green LED Off digitalWrite(LED_RED,HIGH); //Red LED On digitalWrite(RELAY,HIGH); //Turn on Relay (Unlocked) lcd.setCursor(0,1); lcd.print("Door Open "); delay(4000); //Keep Door open for 4 Seconds Lock(); } else { lcd.setCursor(0,1); lcd.print("Invalid Password"); //Display Error Message delay(1500); //Message delay Lock(); } } } //================================================================= // LOCK and Update Display //================================================================= void Lock() { lcd.setCursor(0,1); lcd.print("Door Locked "); delay(1500); lcd.setCursor(0,1); lcd.print(" "); //Clear Password lcd.setCursor(0,1); keycount=0; digitalWrite(LED_GREEN,HIGH); //Green LED Off digitalWrite(LED_RED,LOW); //Red LED On digitalWrite(RELAY,LOW); //Turn off Relay (Locked) } Password Based Door Lock System Using Arduino SIMULINO UNO (Schematic Diagram) The key pad library for the arduino uno available in this link Keypad This library is setup to do every function for the keypad . The simulation file for proteus 8 with arduino code can be downloaded from this link proteus simulation with code This is very simple project . If you did not understood code please learn first AVR and it will be easy for you to understand arduino codes . you can learn AVR from this link https://www.electronify.org/learn-microcontrolleravr If you have any question or suggestion please comment below and do not forget to share this project . For another similar project visit here: Password Based Door Lock System Using Arduino SIMULINO UNO Concise summary (under 100 words): This Arduino-based password door lock uses a 4x4 keypad, LCD, LEDs, and a relay-driven motor to lock/unlock a door. The system masks input with asterisks, checks a 4-digit password (1234), lights LEDs to indicate status, and activates a relay to open the door for 4 seconds on correct entry. Cancel clears input and relocks. The project demonstrates using a relay as a mechanical switch controlled via Arduino and an NPN transistor, with Proteus simulation and keypad library links provided.

Parts used in the Password Based Door Lock System Using Arduino SIMULINO UNO:

  • Arduino Uno (Simulino UNO simulation)
  • 4x4 Matrix Keypad
  • 16x2 Liquid Crystal LCD
  • Relay (to drive lock motor)
  • NPN transistor (for relay control)
  • DC motor or lock actuator
  • Red LED
  • Green LED
  • Resistors (for LEDs and transistor base as required)
  • Wiring, breadboard or PCB

Security presents the primary challenge in today’s modern society. Anyone has the ability to enter your personal residence at any moment in order to steal your belongings. In order to keep your home safe from burglars, you must ensure it is secure. A motor is installed on the door in this project to ensure that the door opens only if the password is correct.

This project will help you understand the concept behind a relay. Relay functions as a mechanical switch for transferring very high voltage with control from a 3 or 5 volt signal using an npn transistor.

Follow the circuit diagram to connect your hardware and then upload the hex file from the provided code to the Arduino Uno board.

Password Based Door Lock System Using Arduino SIMULINO UNO (Code)


#include
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'7','8','9','/'},
{'4','5','6','*'},
{'1','2','3','-'},
{'C','0','=','+'}
};
byte rowPins[ROWS] = {3, 2, 19, 18}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {17, 16, 15, 14}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
const int LED_RED=10; //Red LED
const int LED_GREEN=11; //Green LED
const int RELAY=12; //Lock Relay or motor
char keycount=0;
char code[4]; //Hold pressed keys
//=================================================================
// SETUP
//=================================================================
void setup(){
pinMode(LED_RED,OUTPUT);
pinMode(LED_GREEN,OUTPUT);
pinMode(RELAY,OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Password Access:");
lcd.setCursor(0,1); //Move coursor to second Line
// Turn on the cursor
lcd.cursor();
digitalWrite(LED_GREEN,HIGH); //Green LED Off
digitalWrite(LED_RED,LOW); //Red LED On
digitalWrite(RELAY,LOW); //Turn off Relay (Locked)
}
//=================================================================
// LOOP
//=================================================================
void loop(){
char customKey = customKeypad.getKey();
if (customKey && (keycount<4) && (customKey !='=') && (customKey !='C')){
//lcd.print(customKey); //To display entered keys
lcd.print('*'); //Do not display entered keys
code[keycount]=customKey;
keycount++;
}
if(customKey == 'C') //Cancel/Lock Key is pressed clear display and lock
{
Lock(); //Lock and clear display
}
if(customKey == '=') //Check Password and Unlock
{
if((code[0]=='1') && (code[1]=='2') && (code[2]=='3') && (code[3]=='4')) //Match the password
{
digitalWrite(LED_GREEN,LOW); //Green LED Off
digitalWrite(LED_RED,HIGH); //Red LED On
digitalWrite(RELAY,HIGH); //Turn on Relay (Unlocked)
lcd.setCursor(0,1);
lcd.print("Door Open ");
delay(4000); //Keep Door open for 4 Seconds
Lock();
}
else
{
lcd.setCursor(0,1);
lcd.print("Invalid Password"); //Display Error Message
delay(1500); //Message delay
Lock();
}
}
}
//=================================================================
// LOCK and Update Display
//=================================================================
void Lock()
{
lcd.setCursor(0,1);
lcd.print("Door Locked ");
delay(1500);
lcd.setCursor(0,1);
lcd.print(" "); //Clear Password
lcd.setCursor(0,1);
keycount=0;
digitalWrite(LED_GREEN,HIGH); //Green LED Off
digitalWrite(LED_RED,LOW); //Red LED On
digitalWrite(RELAY,LOW); //Turn off Relay (Locked)
}

Password Based Door Lock System Using Arduino SIMULINO UNO (Schematic Diagram)

Password Based Door Lock System Using Arduino SIMULINO UNO schematic diagram

The key pad library for the arduino uno available in this link Keypad .This library is setup to do every function for the keypad .

The simulation file for proteus 8  with arduino code can be downloaded from this link proteus simulation with code 

This is very simple project . If you did not understood code please learn first AVR and it will be easy for you to understand arduino codes . you can learn AVR from this link https://www.electronify.org/learn-microcontrolleravr

If you have any question or suggestion please comment below and do not forget to share this project .

For another similar project visit here:

Password Based Door Lock System Using Arduino SIMULINO UNO

Quick Solutions to Questions related to Password Based Door Lock System Using Arduino SIMULINO UNO:

  • What is the correct password to unlock the door?
    The code in the article checks for 1 2 3 4 as the correct 4-digit password.
  • How long does the door remain open after entering the correct password?
    The door remains open for 4 seconds as per the code's delay(4000).
  • How does the project hide entered keypad digits?
    The LCD prints an asterisk for each entered key instead of showing the actual digits.
  • What happens when the C key is pressed on the keypad?
    Pressing C calls Lock(), which clears the display, resets input, and turns the relay off (locks the door).
  • Which Arduino pins are used for the LCD in the code?
    The LCD is initialized with pins 9, 8, 7, 6, 5, and 4 in that order.
  • Which pins control the LEDs and relay in the code?
    LED_RED is pin 10, LED_GREEN is pin 11, and RELAY is pin 12.
  • Does the project use a keypad library?
    Yes, the article references the Keypad library for Arduino to handle keypad functions.
  • What indication is shown on the LCD when the password is invalid?
    The LCD displays Invalid Password for a short delay then calls Lock().

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top