Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

How To Make Password-Protected Door Lock Using Arduino UNO DIY Project by WTC Zone

  


This project creates a password-protected door lock using an Arduino UNO, a 4x4 keypad, a servo motor, an I2C LCD, and a buzzer. When powered on, the system waits for the user to press the "" key. Once pressed, it prompts for a password. If the correct password is entered, the servo motor unlocks the door, stays open for 2 seconds, and then locks again.


🛠 Parts Used:

  1. Arduino UNO – The brain of the system.
  2. 4x4 Keypad – Used to input the password.
  3. Servo Motor (SG90 or MG995) – Controls the door lock mechanism.
  4. I2C LCD Display (16x2) – Displays system status.
  5. Buzzer – Provides sound feedback on correct/incorrect password entry.
  6. Breadboard & Jumper Wires – For easy wiring and connections.

🔌 Connections & Circuit Diagram

🔗 Wiring:

ComponentArduino UNO Pins
Keypad (4x4)D2 - D9 (Row & Column Pins)
Servo Motor            PWM Pin D10 (Signal), VCC (5V), GND
 I2C LCD SDA (A4), SCL (A5), VCC (5V), GND
BuzzerD11 (Positive), GND (Negative)

⚡ Circuit Diagram:

(I'll describe it, but you may want to use Fritzing to visualize it.)

  • Connect the 4x4 Keypad to D2–D9.
  • Connect the Servo motor to D10, 5V, and GND.
  • Connect the I2C LCD to SDA (A4) and SCL (A5).
  • Connect the Buzzer to D11 and GND.


Circuit Diagram

Video Link: - Click Here For Video

How To Make Password-Protected Door Lock Using Arduino UNO DIY Project by WTC Zone simple Circuit: -





How To Make Password-Protected Door Lock Using Arduino UNO DIY Project by WTC Zone Arduino Programming: -

Arduino IDE Program

Code for Password-Protected Door Lock Using Arduino UNO DIY Project by WTC Zone


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

// Define I2C LCD (16x2) address 0x27
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Define servo
Servo doorLock;

// Define buzzer pin
#define BUZZER 11

// Define the keypad size and keys
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);

// Set the password
String password = "1234"; // Change as needed
String inputPassword = "";
bool requestPassword = false;
bool doorOpen = false; // Track door state

// Function to play a startup tone
void playStartupTone() {
  tone(BUZZER, 1000, 200);
  delay(300);
  tone(BUZZER, 1500, 200);
  delay(300);
  tone(BUZZER, 2000, 200);
  delay(300);
  noTone(BUZZER);
}

// Function for door opening alert
void doorOpeningTone() {
  tone(BUZZER, 1200, 300);
  delay(350);
  noTone(BUZZER);
}

// Function for door closing alert
void doorClosingTone() {
  tone(BUZZER, 800, 300);
  delay(350);
  noTone(BUZZER);
}

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Door Lock System");

  doorLock.attach(10);
  doorLock.write(0); // Keep door locked initially

  pinMode(BUZZER, OUTPUT);
  digitalWrite(BUZZER, LOW);

  // Play startup tone
  playStartupTone();
 
  delay(2000);
  lcd.clear();
  lcd.print("Press * to Start");
}

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

  // If * is pressed, start password entry
  if (key == '*') {
    requestPassword = true;
    inputPassword = "";
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Enter Password:");
  }

  // If entering password, collect input
  if (requestPassword && key && key != '*' && key != '#' && key != 'D') {
    inputPassword += key;
    lcd.setCursor(inputPassword.length(), 1);
    lcd.print('*'); // Hide actual input
  }

  // Check password when # is pressed
  if (key == '#' && requestPassword) {
    if (inputPassword == password) {
      lcd.clear();
      lcd.print("Access Granted");

      // Beep once for success
      tone(BUZZER, 1000, 200);
      delay(300);
      noTone(BUZZER);

      // Play door opening alert
      doorOpeningTone();

      // Open door
      doorLock.write(90);
      doorOpen = true; // Mark door as open
      lcd.clear();
      lcd.print("Door Open");
      lcd.setCursor(0, 1);
      lcd.print("Press D to Close");
    } else {
      lcd.clear();
      lcd.print("Wrong Password!");

      // Beep twice for wrong password
      for (int i = 0; i < 2; i++) {
        tone(BUZZER, 2000, 200);
        delay(300);
      }
      noTone(BUZZER);

      delay(2000);
      lcd.clear();
      lcd.print("Press * to Start");
    }
   
    inputPassword = "";
    requestPassword = false;
  }

  // If door is open and 'D' is pressed, close the door
  if (key == 'D' && doorOpen) {
    lcd.clear();
    lcd.print("Closing Door...");

    // Play door closing alert
    doorClosingTone();

    // Close door
    doorLock.write(0);
    doorOpen = false; // Mark door as closed
    delay(2000);
   
    lcd.clear();
    lcd.print("Press * to Start");
  }
}

 
 

-------------------------------------------------------------------------------------------------------------------------------

⚙️ How It Works

  1. When powered on, the LCD displays "Press * to Start".
  2. The user presses "" on the keypad to start the password entry.
  3. The LCD prompts "Enter Password:", and the user types the password (masked as '*').
  4. Pressing "#" submits the password:
    • Correct password → Displays "Access Granted", activates servo motor, unlocks the door for 2 seconds, and then locks it again.
    • Wrong password → Displays "Wrong Password!", buzzer beeps, and prompts the user to restart.

💡 Tips & Tricks

  • Use EEPROM: Store passwords in EEPROM memory so they don’t reset when power is lost.
  • Multiple Users: Modify the code to allow multiple stored passwords.
  • Change Password Option: Add an admin mode to modify the password via the keypad.
  • Stronger Security: Implement RFID or Fingerprint Sensor for better security.
  • Logging Attempts: Store failed attempts in a database for tracking.

🔧 Further Modifications & Future Enhancements

  • Wi-Fi or Bluetooth Integration – Control the door lock with a mobile app.
  • Auto-Lock Feature – If an incorrect password is entered 3 times, the system locks for a set period.
  • Face Recognition – Use an AI camera module for biometric authentication.

✅ Final Thoughts

This project provides a simple, secure, and customizable password-based door lock using an Arduino UNO, keypad, and servo motor. It can be enhanced with additional security features like RFID, mobile app control, or AI-based authentication.


Let me know if you need further help with the implementation or enhancements! 😊


Share, Support, and Subscribe!!! 1. PRO KAM EXPLAINED 2. Knowledge KAM 3. PRO KAM Follow us on 1. Facebook 2. Instagram 3. Pinterest 4. Blogspot 5 Twitter If you have any other ideas to make me design, you can describe them in the comment section and if I can, I will make a designing video on it. So I am waiting #prokam #wtc #Arduino #ideas #projects #diy #how #to #ArduinoProjects #UltrasonicSensor #HeightMeasurement #TechDIY #WeTechCreators #wtczo

Post a Comment

0 Comments

Ad Code

Responsive Advertisement