Passcode Door Lock


The passcode door lock utilizing Arduino technology is a secure and customizable access control system designed to safeguard entry into homes, offices, or other spaces. This innovative device features a keypad for users to input a pre-set code, with Arduino serving as the central processing unit. Upon entering the correct code, the door lock mechanism is triggered to unlock, granting access to authorized individuals. Arduino facilitates the management of the passcode database and the execution of security protocols, ensuring reliability and flexibility. Additionally, the system can be enhanced with features such as remote monitoring, logging of access attempts, and integration with other smart home systems. Overall, the passcode door lock offers a convenient, efficient, and scalable solution for controlling access to various environments while prioritizing security and user convenience.


 Circuit Diagram :-



Code :-


// BY Arduino techy
				​//
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Servo.h>

#define Password_Length 5

Servo myservo;
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

int pos = 0;

char Data[Password_Length];
char Master[Password_Length] = "1234";
byte data_count = 0, master_count = 0;

bool Pass_is_good;
bool door = false;
char customKey;


/*---preparing keypad---*/

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] = {0, 1, 2, 3};
byte colPins[COLS] = {4, 5, 6, 7};

Keypad customKeypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);


/*--- Main Action ---*/
void setup()
{
  myservo.attach(9, 2000, 2400);
  ServoClose();
  lcd.begin(16, 2);
  lcd.print("Protected Door");
  loading("Loading");
  lcd.clear();
}


void loop()
{
  if (door == true)
  {
    customKey = customKeypad.getKey();
    if (customKey == '#')
    {
      lcd.clear();
      ServoClose();
      lcd.print("Door is closed");
      delay(3000);
      door = false;
    }
  }
  else
    Open();

}

void loading (char msg[]) {
  lcd.setCursor(0, 1);
  lcd.print(msg);

  for (int i = 0; i < 9; i++) {
    delay(1000);
    lcd.print(".");
  }
}

void clearData()
{
  while (data_count != 0)
  { 
    Data[data_count--] = 0;
  }
  return;
}

void ServoClose()
{
  for (pos = 90; pos >= 0; pos -= 10) { 
    myservo.write(pos);
  }
}

void ServoOpen()
{
  for (pos = 0; pos <= 90; pos += 10) {
    myservo.write(pos);  
  }
}

void Open()
{
  lcd.setCursor(0, 0);
  lcd.print("Enter Password");
  
  customKey = customKeypad.getKey();
  if (customKey)
  {
    Data[data_count] = customKey;
    lcd.setCursor(data_count, 1);
    lcd.print(Data[data_count]);
    data_count++;
  }

  if (data_count == Password_Length - 1)
  {
    if (!strcmp(Data, Master))
    {
      lcd.clear();
      ServoOpen();
      lcd.print(" Door is Open ");
      door = true;
      delay(5000);
      loading("Waiting");
      lcd.clear();
      lcd.print(" Time is up! ");
      delay(1000);
      ServoClose();
      door = false;      
    }
    else
    {
      lcd.clear();
      lcd.print(" Wrong Password ");
      door = false;
    }
    delay(1000);
    lcd.clear();
    clearData();
  }
}


Components :-

brown Around computer motherboard

Arduino Uno

Buying Link - 

https://amzn.to/3JkExhm


Servo Motor

 Buying Link - 

https://amzn.to/3U4K9RE

Keypad

Buying Link - 

 https://amzn.to/3xEcuXH

LCD Display

 Buying Link - 

https://amzn.to/4cWzv8n

Jumper Wires

Buying Link - 

https://amzn.to/3W5Ie1Z


Note :-

If you are getting error in the code because you have not installed the libraries.

You have to install the libraries.


Smart Dustbin