In this project, we will build a Smart Door Lock System using Arduino, 4×4 Keypad, Servo Motor, Buzzer, and 16×2 I2C LCD Display. Users can enter a password using the keypad. If the password is correct, the servo motor unlocks the door. If the password is incorrect, the buzzer alerts the user.
This project is perfect for beginners learning:
- Arduino
- Keypad interfacing
- Servo motor control
- I2C LCD display
- Password-based security systems
Components Required
| Component | Quantity |
|---|---|
| Arduino Uno/Nano | 1 |
| 4×4 Matrix Keypad | 1 |
| SG90 Servo Motor | 1 |
| 16×2 I2C LCD Display | 1 |
| Buzzer | 1 |
| Jumper Wires | As required |
| Breadboard (Optional) | 1 |
Circuit Connections
🔢 Keypad Connections
| Keypad Pin | Arduino Pin |
|---|---|
| R1 | 9 |
| R2 | 8 |
| R3 | 7 |
| R4 | 6 |
| C1 | 5 |
| C2 | 4 |
| C3 | 3 |
| C4 | 2 |
Servo Motor Connections
| Servo Wire | Arduino |
|---|---|
| Red | 5V |
| Brown/Black | GND |
| Orange/Yellow | Pin 10 |
Buzzer Connections
| Buzzer | Arduino |
|---|---|
| Positive (+) | Pin 11 |
| Negative (-) | GND |
I2C LCD Connections
| I2C LCD Pin | Arduino Uno/Nano |
|---|---|
| VCC | 5V |
| GND | GND |
| SDA | A4 |
| SCL | A5 |
Important Notes
Servo Power Issue
Servo motors sometimes draw high current and may not work properly using only USB power.
Symptoms:
- Servo jitter
- Weak movement
- Arduino reset
Recommended Solution
Use external 5V power for servo:
- 4×AA battery pack
- 5V adapter
- Power bank
IMPORTANT:
Connect Arduino GND and external power GND together.
LCD Not Displaying Text?
If LCD does not display text:
- Adjust the blue potentiometer on the I2C module
- Try changing I2C address from 0x27 to 0x3F
Required Arduino Libraries
Install these libraries from Arduino IDE Library Manager:
- Keypad
- Servo
- LiquidCrystal_I2C
How the Smart Door Lock Works
- LCD displays “Enter Password”
- User enters password using keypad and Press # key
- If password is correct, LCD shows Access Granted
- Servo rotates and unlocks the door
- After 5 seconds, door locks automatically
- If password is incorrect, LCD displays as “Wrong Password”
- Buzzer beeps 3 times, the press * key to clear entered password
Please Note – Default Password is 1234 but You can change it in code
Arduino Code:
#include <Keypad.h>
#include <Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// ===== LCD =====
LiquidCrystal_I2C lcd(0x27, 16, 2);
// ===== KEYPAD SETTINGS =====
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'}
};
// ===== KEYPAD CONNECTIONS =====
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// ===== SERVO =====
Servo lockServo;
int servoPin = 10;
// ===== BUZZER =====
int buzzerPin = 11;
// ===== PASSWORD =====
String correctPassword = "1234";
String enteredPassword = "";
void setup() {
Serial.begin(9600);
// ===== LCD START =====
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Smart Door Lock");
lcd.setCursor(0, 1);
lcd.print("Enter Password");
// ===== SERVO =====
lockServo.attach(servoPin);
// ===== BUZZER =====
pinMode(buzzerPin, OUTPUT);
// ===== LOCK POSITION =====
lockServo.write(0);
delay(2000);
lcd.clear();
lcd.print("Enter Password");
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.print("Pressed: ");
Serial.println(key);
// ===== DISPLAY * =====
if (key != '#' && key != '*') {
enteredPassword += key;
lcd.setCursor(0, 1);
for (int i = 0; i < enteredPassword.length(); i++) {
lcd.print("*");
}
}
// ===== CHECK PASSWORD =====
if (key == '#') {
lcd.clear();
if (enteredPassword == correctPassword) {
Serial.println("Access Granted");
lcd.setCursor(0, 0);
lcd.print("Access Granted");
// Servo unlock
lockServo.write(90);
delay(5000);
// Servo lock
lockServo.write(0);
lcd.clear();
lcd.print("Door Locked");
}
else {
Serial.println("Wrong Password");
lcd.setCursor(0, 0);
lcd.print("Wrong Password");
// Buzzer alert
for (int i = 0; i < 3; i++) {
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
}
}
enteredPassword = "";
delay(2000);
lcd.clear();
lcd.print("Enter Password");
}
// ===== CLEAR PASSWORD =====
if (key == '*') {
enteredPassword = "";
lcd.clear();
lcd.print("Password Cleared");
delay(1000);
lcd.clear();
lcd.print("Enter Password");
}
}
}
Future Improvements
You can upgrade this project by adding:
- RFID module
- Fingerprint sensor
- ESP32 WiFi control
- Solenoid lock
- Mobile app unlock
- OTP verification
- Emergency exit button
Video Tutorial
You can also watch the complete video tutorial on my YouTube channel for step-by-step explanation and demonstration.