• Password-Based Security System

    • 1. Introduction
      This project demonstrates how to design a simple security system using an Arduino, keypad, and servo motor (acting as a lock).
      The system unlocks only when the correct password is entered. It’s a good foundation for door locks, safes, and access control systems.

      ComponentQuantityDescription
      Arduino Uno1Main controller board
      4×4 Keypad1For password input
      Servo Motor (SG90)1Acts as the door lock
      16×2 LCD Display1To show status messages
      Breadboard and jumper wiresFor connections
      Buzzer (optional)1To give alarm or sound feedback

      3. Circuit Connections
      🔌 Keypad → Arduino
      Keypad PinArduino Pin
      R1 → 9
      R2 → 8
      R3 → 7
      R4 → 6
      C1 → 5
      C2 → 4
      C3 → 3
      C4 → 2
      ComponentArduino PinDescription
      Servo signal10Lock control
      LCD RS12Display control
      LCD EN11Enable signal
      LCD D4–D7A0–A3Data pins
      Buzzer13Optional alert

      #include <Keypad.h>
      #include <LiquidCrystal.h>
      #include <Servo.h>
      // LCD setup
      LiquidCrystal lcd(12, 11, A0, A1, A2, A3);
      // Servo setup
      Servo lockServo;
      // Keypad setup
      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] = {9, 8, 7, 6};
      byte colPins[COLS] = {5, 4, 3, 2};
      Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
      // Variables
      String password = "1234";
      String input = "";
      void setup() {
      lcd.begin(16, 2);
      lcd.print("Enter Password:");
      lockServo.attach(10);
      lockServo.write(0); // locked position
      pinMode(13, OUTPUT); // buzzer
      }
      void loop() {
      char key = keypad.getKey();
      if (key) {
      if (key == '#') {
      if (input == password) {
      lcd.clear();
      lcd.print("Access Granted");
      lockServo.write(90); // unlock
      digitalWrite(13, LOW);
      delay(3000);
      lockServo.write(0); // lock again
      lcd.clear();
      lcd.print("Enter Password:");
      } else {
      lcd.clear();
      lcd.print("Wrong Password!");
      digitalWrite(13, HIGH);
      delay(2000);
      digitalWrite(13, LOW);
      lcd.clear();
      lcd.print("Enter Password:");
      }
      input = "";
      } else if (key == '*') {
      input = "";
      lcd.clear();
      lcd.print("Enter Password:");
      } else {
      input += key;
      lcd.setCursor(0, 1);
      lcd.print("*");
      }
      }
      }
      When the system starts, the LCD shows:
      “Enter Password:”
      The user enters digits using the keypad.
      Each key press is shown as “*” on the LCD for security.
      When the user presses ‘#’, Arduino checks the input:
      ✅ If the password is correct, the servo rotates (door unlocks).
      ❌ If the password is wrong, the buzzer sounds an alarm.
      The door automatically locks again after a few seconds.
      6. Possible Upgrades

      Add EEPROM to save password permanently
      Use keypad input to change password
      Add RFID reader or fingerprint sensor
      Connect to Blynk app or Wi-Fi for remote access
      Add motion sensor + camera for smart security
      7. Applications
      🔒 Smart home door locks
      🏫 School lab security systems
      🏢 Office access control
      🧳 Safe and locker systems