Learn PCB Design

PCB design is a must tool to learn to be Industry ready for every electronics engineer. Learn PCB design online in just 20 days and boost your career. Work as freelancer and earn a high amount daily by spending only 2 hours a day part time. contact on WhatsApp number +917990850788

Full width home advertisement

Electronics

PCB Design

Post Page Advertisement [Top]

 

Introduction

Security systems based on embedded controllers are widely used in modern access-control applications. A password-based door lock system using Arduino is a simple but effective embedded project that demonstrates how microcontrollers interact with input devices, output indicators, and actuators to implement authentication logic.

In this project, a 4×4 keypad is used to enter a password, an Arduino Uno processes the input, and a servo motor simulates the locking and unlocking action of a door. A 16×2 LCD display provides user feedback, while LED indicators and a buzzer signal whether the entered password is correct or incorrect.

This project is an excellent example of integrating digital input scanning, actuator control, and real-time status feedback in an embedded system.


Objective of the Project

The objective of this system is to design a microcontroller-based password-protected locking mechanism that:

  • accepts a 4-digit password from a keypad

  • verifies the entered password

  • unlocks the door when the password is correct

  • generates an alert when the password is incorrect

  • displays system status on an LCD

The programmed password used in this system is:

1234


Components Required

The following components are used to implement the password-based locking system:

ComponentQuantity
Arduino Uno1
16×2 LCD Display1
4×4 Matrix Keypad1
Micro Servo Motor1
Red LED1
Green LED1
Piezo Buzzer1
NPN Transistor1
1kΩ Resistors2
160Ω Resistors2
Connecting WiresAs required

Block Diagram Description

The system consists of five major functional modules:

1. Input Module

The 4×4 keypad is used for entering the password. Each key press sends a digital signal to Arduino.

2. Processing Module

The Arduino Uno reads keypad input and compares it with the stored password.

3. Display Module

The 16×2 LCD shows system messages such as:

Insert Password
Door Unlock
Password Invalid

4. Output Indication Module

Two LEDs indicate system status:

Green LED → Correct password
Red LED → Wrong password

5. Actuation Module

The servo motor rotates to simulate door unlocking.




Working Principle of the System

The working of this project is based on password authentication logic implemented inside the Arduino program.

When the system starts:

  1. LCD displays:

    Insert Password

  2. User enters four digits using keypad

  3. Arduino stores each digit temporarily

  4. Entered password is compared with stored password

If password matches:

  • Servo rotates

  • Door unlocks

  • Green LED turns ON

  • LCD shows status message

If password does not match:

  • Red LED turns ON

  • Buzzer activates

  • LCD shows error message

This process repeats continuously.



Circuit Operation Explanation

The Arduino acts as the central controller of the system.

Keypad Interface

The keypad operates using row-column scanning technique. When a key is pressed:

  • corresponding row and column connect internally

  • Arduino detects pressed key location

  • converts location into digit value

The keypad library simplifies scanning operation.


LCD Interface

The LCD operates in 4-bit mode to reduce required Arduino pins.

LCD displays:

Insert Password
Door Lock
Door Unlock
Password Invalid

This improves user interaction with the system.


Servo Motor Control

Servo motor position determines door state.

Two positions are defined in code:

posOpen = 0°
posClose = 90°

Servo rotates to unlocking position after correct password entry.



LED Indication System

Two LEDs provide visual confirmation.

Green LED indicates:

Correct password entered

Red LED indicates:

Incorrect password entered

This improves reliability of user feedback.


Buzzer Alert Circuit

A piezo buzzer generates warning sound when incorrect password is entered.

The buzzer is driven through an NPN transistor because:

Arduino cannot safely drive buzzer directly at higher current loads.

Transistor works as switching device.


Software Logic Explanation

The program uses three important Arduino libraries:

LiquidCrystal.h
Keypad.h
Servo.h

Each library performs a specific function.

LiquidCrystal Library

Controls LCD display operations.

Example:

lcd.begin(16,2);

Initializes LCD in 16×2 mode.


Keypad Library

Detects pressed key using matrix scanning.

Example:

char key = keypad.getKey();

Returns pressed key value.


Servo Library

Controls servo rotation angle.

Example:

myservo.write(posClose);

Moves servo to lock position.


Password Verification Logic

The entered password digits are stored sequentially:

a
b
c
d

These digits are compared with stored password values:

C1 = 1
C2 = 2
C3 = 3
C4 = 4

Verification condition:

if(a==C1 && b==C2 && c==C3 && d==C4)

If condition becomes TRUE:

System unlocks door.

Otherwise:

System generates alert.


complete code for the system

#include <LiquidCrystal.h>   

#include <Keypad.h>

#include <Servo.h>


int servostate;

int posOpen = 0;

int posClose = 90;

int a=0, b=0, c=0, d=0;

int var=0; 

int C1=1,C2=2,C3=3,C4=4;//password "1234"

int Buzzer = A3;

char f='*';  

const byte row = 4; 

const byte column = 4;

char hex[row][column] = {

  {'1','2','3'},

  {'4','5','6'},

  {'7','8','9'},

  {'*','0','#'}

};

byte pinRow[row] = {0, 6, 5, 4}; //connect to the row pinouts of the keypad

byte pinColumn[column] = {3, 2, 1};//connect to the column pinouts of the keypad

Servo myservo;

Keypad keypad = Keypad( makeKeymap(hex), pinRow, pinColumn, row, column );

//initialize the internal keymap to be equal to the user defined key map

//Defines an object Keypad of the class Keypad and initializes it.

LiquidCrystal lcd(8,9,10,11,12,13);

void setup(){

  lcd.begin(16,2); 

  pinMode(A0,OUTPUT); 

  pinMode(A1,OUTPUT); 

  myservo.attach(7); 

  myservo.write(posOpen);

  servostate = 1;

}

void loop(){  

  char key = keypad.getKey();//Returns the key that is pressed, if any. This function is non-blocking.

  if (key){

   lcd.setCursor(6+var,1);

   lcd.print(key),lcd.setCursor(6+var,1),lcd.print(f);

   key=key-48;

   var++; 

   switch(var){

    case 1:

    a=key; 

    break;

    case 2:

    b=key; 

    break;

    case 3:

    c=key; 

    break;

    case 4:

    d=key;  

   delay(50);

  if(a==C1 && b==C2 && c==C3 && d==C4){

    lcd.clear();

    lcd.setCursor(4,0);

    lcd.print("Door");

    lcd.setCursor(5,1);

    if(servostate == 0){

    lcd.print("lock");

      delay(3000);

      myservo.write(posOpen);

      servostate = 1;      

    }

    else{

      lcd.print("UnLock");

      myservo.write(posClose);

      servostate = 1;

      delay(2000);

      myservo.write(posOpen);

    }

    digitalWrite(A0,HIGH);

    delay(1000); 

    lcd.clear();

    digitalWrite(A0,LOW);

    }

  else{

    lcd.clear();

    lcd.setCursor(4,0);

    lcd.print("Password");

    lcd.setCursor(4,1);

    lcd.print("Invalid");

    digitalWrite(Buzzer,HIGH);

    digitalWrite(A1,HIGH); 

    delay(3000); 

    lcd.clear();

    digitalWrite(A1,LOW);

    digitalWrite(Buzzer,LOW);

    }


   var=0;

   lcd.clear();


  break;

  }

 }

 if(!key){lcd.setCursor(0,0),lcd.print("Insert Password");}

}


System Operation Flow

The complete operation sequence is:

Step 1
Power ON system

Step 2
LCD displays:

Insert Password

Step 3
User enters password

Step 4
Arduino compares password

Step 5

If correct:

Servo rotates
Green LED ON
LCD shows Unlock message

If incorrect:

Red LED ON
Buzzer activates
LCD shows Invalid Password

Step 6
System resets and waits for next entry


Advantages of the System

This embedded system offers several advantages:

Simple circuit design
Low implementation cost
High reliability
Real-time password verification
User-friendly LCD interface
Expandable for advanced security system



Applications of Password Based Door Lock System

This system can be used in:

Home security systems
Office access control
Laboratory equipment protection
Digital lockers
Attendance control systems
Industrial access panels


Possible Improvements in Future Design

This system can be upgraded further by adding:

EEPROM password storage
RFID authentication
Bluetooth unlocking
Fingerprint sensor integration
GSM alert notification
Mobile app control

These improvements increase system security level.


Conclusion

The Arduino-based password protected door lock system demonstrates how embedded controllers can be used to implement reliable authentication mechanisms using simple hardware components. 


The integration of keypad input, LCD feedback, servo motor control, LED indicators, and buzzer alerts makes this project a strong example of a practical embedded security application. It also provides an excellent foundation for developing more advanced smart access control systems in future embedded designs.







No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib