Arduino Password Door Lock With Buzzer

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1.

Arduino Automatic Password Door Lock with Buzzer

The project is designed to protect the door lock mechanism using password. It is hard to
manage keys and keep it safe from others getting their hands on it. With the help of a
microcontroller and keypad we can set a password which is only known to the user. The
door shall open when the correct password is typed and automatically lock after a
certain time delay. A buzzer is added to the circuit to ensure the keys of the keypads
are pressed properly which adds a nice touch to our circuit.

Components List:

1. Arduino UNO
2. 12V Solenoid
3. 5V Relay Module
4. Keypad
5. Buzzer
6. 12V Adapter
7. Jumper Wires

Procedure:

Step-1: Connect the keypad and buzzer to the digital pins of arduino uno by seeing the
diagram below.

Step-2: Take 5V input from arduino and connect to DC+ pin of relay. Furthermore,
connect the ground of the arduino with DC- pin of the relay. Finally, the A5 pin of the
arduino is connected to the trigger pin, IN of the relay.

Step-3: The positive wire from the 12V adapter is connected to the NO pin of the relay
while the ground is shorted with the negative wire of solenoid lock. The positive wire of
the solenoid is connected to the COM pin of the relay.

- When IN is LOW level signal, the NO does not connect with COM, hence solenoid
stays locked
- When IN is a HIGH level signal, the NO connects with COM and solenoid is activated
making it unlock.

Step-4: Connect the arduino uno board to the pc and upload the given code below in
the Arduino IDE. In the code you can change the password as you like. Power on your
adapter and press the password. Now you have your very own password protected door
lock 🙂

Diagram:

Fig: Arduino Password Door Lock Connections


Code:

#include <Keypad.h>
#include <ezBuzzer.h>

const int RELAY_PIN = A5; // the Arduino pin, which connects to the IN
pin of relay
const int ROW_NUM = 4; // four rows
const int COLUMN_NUM = 4; // four columns
const int OUTPUT_PIN = 10;
const int BUZZER_PIN = 11;

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

byte pin_rows[ROW_NUM] = {9, 8, 7, 6}; //connect to the row pinouts of the


keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; //connect to the column
pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM,


COLUMN_NUM );
ezBuzzer buzzer(BUZZER_PIN); // create ezBuzzer object that attach to a
pin;

const String password_1 = "1A33C"; // change your password here


const String password_2 = "49DA2"; // change your password here
const String password_3 = "AA22B"; // change your password here
String input_password;

void setup() {
Serial.begin(9600);
input_password.reserve(32); // maximum input characters is 33, change if
needed
pinMode(RELAY_PIN, OUTPUT); // initialize pin as an output.
digitalWrite(RELAY_PIN, LOW); // lock the door
buzzer.beep(100);

void loop() {
buzzer.loop(); // MUST call the buzzer.loop() function in loop()
char key = keypad.getKey();

if (key){
Serial.println(key);
buzzer.beep(100); // generates a 100ms beep

if(key == '#') {
input_password = ""; // reset the input password
} else if(key == '*') {
if(input_password == password_1 || input_password == password_2 ||
input_password == password_3) {
Serial.println("The password is correct");
digitalWrite(RELAY_PIN, HIGH);
delay(5000);
digitalWrite(RELAY_PIN, LOW);

} else {
Serial.println("The password is incorrect, try again");
}

input_password = ""; // reset the input password


} else {
input_password += key; // append new character to input password
string
}
}
}

You might also like