Arduino Keyless Door Lock System | Arduino Project

by | May 11, 2022 | Arduino, Basic Coding, Coding


In this Arduino project tutorial, we will create an Arduino Keyless Door Lock System With Keypad And LCD. For this, we will use a micro servo which will act as a lock, an LCD will be used for display purposes and a keypad to enter the password.

In order to build physical projects, the components can be purchased online or from any electronics centre.

For the online projects, the TinkerCad website can be used.



In order to make Arduino Keyless Door Lock System With Keypad And LCD, we will require the following components:


  • Arduino Uno R3
  • 1 KeyPad 4×4
  • LCD 16×2
  • 1 micro servo
  • 1 small BreadBoard
  • 2 LEDs
  • 3 Resistors
  • Connecting wires

Circuit Diagram

Arduino Keyless Door Lock System With Keypad And LCD

Steps To Make Arduino Keyless Door Lock System

Step 1: Gather all the components on the Digital Board or Physical Table.

Step 2: Plug LEDs on the BreadBoard.

Micro Servo:

Step 3: Connect the Ground Terminal of it to the Ground(GND) pin of the Arduino using a black coloured wire.

Step 4: Connect the signal terminal of it to the 7 number pin of the Arduino Uno.

Step 5: Connect the Power terminal of it to the 5V power supply pin of the Arduino Uno.


Step 6: Connect the Cathode Terminal of each to the Ground(GND) pin of the Arduino using a black coloured wire thru a resistor, as shown in the figure.

Step 7: Connect the Anode terminal of each to the A0 & A1 pin number of the Arduino, respectively, as shown in the figure.


Step 8: Connect the Row 1 to 4 and Column 1 to 3 of it to the 0 to 6 number pins of the Arduino, respectively, as shown in the figure.


Step 9: Connect the Power & the LED anode terminal of it to the 5V pin of the Arduino.

Step 10: Connect the Ground, Contrast, Read/Write & LED cathode terminals of it to the GND pin of the Arduino, as shown in the circuit.

Step 11: Connect the Register Select, Enable, & DB4 to DB7 pins of it to the 8 to 13 number pins of the Arduino, respectively, as shown in the figure.

Source Code

#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Servo.h>
int servoState;
int open = 0;
int close = 90;
int a = 0, b = 0, c = 0, d = 0;
int var = 0;
int C1 = 1, C2 = 2, C3 = 3, C4 = 4;
char f='*';
const byte rows = 4;
const byte columns = 3;
char keyPad[rows][columns] =
byte pinRows[rows] = {0, 6, 5, 4};
byte pinColumns[columns] = {3, 2, 1};
Servo lock;
Keypad keypad = Keypad(makeKeymap(keyPad), pinRows, pinColumns, rows, columns );
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup()
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
servoState = 1;

void loop()
char key = keypad.getKey();
lcd.setCursor(6+var, 1), lcd.print(key);
lcd.setCursor(6+var, 1), lcd.print(f);
key = key - 48;

case 1: a = key;
case 2: b = key;
case 3: c = key;
case 4: d = key;


if(a == C1 && b == C2 && c == C3 && d == C4)
lcd.print(" Welcome ");
lcd.print(" Human !");

digitalWrite(A0, HIGH);
digitalWrite(A0, LOW);
digitalWrite(A1, HIGH);
digitalWrite(A1, LOW);
var = 0;
lcd.setCursor(0, 0), lcd.print("Enter Password :");

Explanation of the Code

In the beginning, we have included three header files for LCD, Keypad and servo, respectively.

1. Firstly, we have initialised class arrays and variables that will be required in the function.

2. In the setup function, we have configured the LED pins for output purposes and defined the servo state to close at the beginning.

3. In the loop function, we take the key and print it in an asterisk for privacy and confidentiality. Simultaneously taking the keys using a switch case and matching the key entered to the password that we have set in the keypad using the if statement and proceeding further using the if-else statement. In case the entered key does not match the predefined key array, we are printing the incorrect password in the LCD using its cursor.

4. The servo will be at 90 degrees initially, and when the password matches, it will rotate to 0 degrees.

5. In case of success, we are glowing green LED by giving it High power; else, Red LED will glow for a second.


Arduino Keyless Door Lock System With Keypad And LCD

We will get the following output on the successful completion of the project.

On starting, the Servo will be at a 90-degree angle from its regular position and on entering the correct password(1234), it will turn to 0 degrees, and the lock will open in this way.

Entering the incorrect password will not change its axis, and the LCD will display “Incorrect password”.


You May Also Like To Create…


Submit a Comment

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