Translate

Arduino Keypad Password Door Lock System

 1. Introduction

This project explains how to build an Arduino keypad password door lock system using a 4x4 keypad and a servo motor. The door unlocks only when the correct password is entered, making it a simple security system.


2. Components

  • Arduino Nano /Uno
  • 4x4 Keypad
  • Servo Motor (SG90)
  • Jumper wires
  • Breadboard

3. Circuit and Connections

Arduino Nano Pinout Diagram


Pinout Diagram of SG90 Servo Motor



Pinout Diagram 4X4 Matrix Keypad

Keypad Connections:

R1 → D2
R2 → D3
R3 → D4
R4 → D5
C1 → D6
C2 → D7
C3 → D8
C4 → D9

Servo Motor Connections:
VCC → 5V
GND → GND
Signal → D10


4. Circuit Working

When a key is pressed on the keypad, Arduino reads the input and stores it. Once four digits are entered, Arduino compares it with the predefined password.

  • If correct → Servo rotates and unlocks the door
  • If wrong → No action is taken

After a few seconds, the door locks again automatically.


5. Code

#include <Keypad.h>
#include <Servo.h>

Servo myServo;

const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {6,7,8,9};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

String password = "1234";
String input = "";

void setup() {
myServo.attach(10);
myServo.write(0);
}

void loop() {
char key = keypad.getKey();

if (key) {
input += key;

if (input.length() == 4) {
if (input == password) {
myServo.write(90);
delay(3000);
myServo.write(0);
}
input = "";
}
}
}

6. Code Working

  • The keypad reads user input
  • The entered digits are stored in a string
  • When 4 digits are entered, it checks with the stored password
  • If matched, servo rotates to unlock
  • After delay, it returns to lock position

7. Tips

  • Use a strong password instead of "1234"
  • Add a buzzer for wrong attempts
  • Use external power if servo is unstable
  • You can add LCD for better display

8. Uses

  • Home security systems
  • Locker systems
  • Office access control
  • Electronic door locks

9. Conclusion

This project demonstrates a simple and effective Arduino-based security system using a keypad and servo motor. It is ideal for beginners and practical applications.

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.