Digital Security Door Lock using Arduino

Digital Security Door Lock using Arduino
In this project we will make a digital door lock system with keypad using Arduino Uno. It will open your door only when the right password is entered and it will start beeping when a wrong password is entered. To avoid thefts are increasing day by day security is becoming a major concern nowadays.
Components Required:
1. 4×4 keypad
2. LCD (16×2)
3. Arduino Uno
4. Push Pull Solenoid
5. Servo Motor
6. Power Supply
7. 1KΩ, 220Ω Resistor
8. 10KΩ Potentiometer
9. Buzzer

Circuit Diagram & Explanation:
First of all, we will make the connection to the 4×4 Keypad. For connecting the keypad with the Arduino we are using both analog and digital pins. We used analog pins since we need more that 14 digitals pins for this project. If you are using Arduino Mega, then there is no need to use analog pins. Connect first six pins of keypad to analog pins A0 ~ A5 of Arduino and remaining two to digital pins 3 and 2.
To connect the push pull solenoid with the Arduino, we will have to use external power because it requires 6 ~ 12V to operate and much more current than the Arduino can provide. So to do that, we will use TIP120 NPN transistor as a switch/driver and a DC power source which can provide 6 ~ 12V. The NPN transistor will switch ON when we will give HIGH to its base. So, connect its first pin (which is the base pin) to the pin 11 through to a 1KΩ resistor, second pin (which is the collector pin) to the negative wire of push pull solenoid and third pin (which is the emitter pin) to the ground. Now connect the positive of power supply to the positive wire of solenoid and the negative of power supply to the ground.

Connection the 16×2 LCD to the Arduino:
1. Connect pin 1 (VEE) to the ground.
2. Connect pin 2 (VDD or VCC) to the 5V of the Arduino.
3. Connect pin 3 (V0) to the middle pin of the 10KΩ potentiometer and connect the other two ends of the potentiometer to VCC and GND. The potentiometer is used to control the contrast of the LCD.
4. Connect pin 4 (RS) to the pin 9 of the Arduino. This is Register Select pin used to select a particular register in the LCD driver, which is handled by the LCD library.
5. Connect pin 5 (Read/Write) to the ground of Arduino. This pin is not often used so we will connect it to the ground as we are only writing data to LCD.
6. Connect pin 6 (E) to the pin 8 of the Arduino. It is used indicate a valid data or command in the following data pins.
7. The following four pins are data pins which are used to send data or commands to the LCD.
8. Connect pin 11 (D4) to pin 7 of Arduino.
9. Connect pin 12 (D5) to pin 6 of Arduino.
10. Connect pin 13 (D6) to pin 5 of Arduino.
11. Connect pin 14 (D7) to pin 4 of Arduino.
12. Connect pin 15 to the VCC through the 220 ohm resistor. By changing this resitor value we can change the backlight LED brightness. Larger values will make the back light much more darker.
13. Connect pin 16 to the Ground.

Working Details:
In this project, we have used EEPROM in the Arduino to store the password in it. The default password stored in it will be ‘1234’. When we enter a password, it will match it with the password stored in the Arduino EEPROM. If it is correct, then it will show ‘Passkey Accepted’ and the push pull solenoid will come in low state (Door Unlocked). If the password is wrong, then it will show ‘Access Denied’. During this condition the buzzer will start beeping and the push pull solenoid will remain in the high state (Door Locked). The buzzer will also beep once when any key is pressed.
For changing the passkey, we have to press ‘#’. When we press ‘#’, it will ask for current passkey. If we enter the correct password it will ask for new passkey and will save it in the EEPROM.

Download: proteus simulation androiderode digital door lock 

Arduino Code or Sketch: 

#include <Keypad.h>
#include<LiquidCrystal.h>
#include<EEPROM.h>
LiquidCrystal lcd(9,8,7,6,5,4);
char password[4];
char pass[4],pass1[4];
int i=0;
char customKey=0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {A0,A1,A2,A3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A4,A5,3,2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
int led;
int buzzer = 10;
int m11;
int m12;
void setup()
{
Serial.begin(9600);
pinMode(11, OUTPUT);
lcd.begin(16,2);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(m11, OUTPUT);
pinMode(m12, OUTPUT);
lcd.setCursor(0,0);
lcd.print(" DOOR SAFTY ");
lcd.setCursor(0,1);
lcd.print(" KEYPAD LOCK ");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Androiderode");
lcd.setCursor(0,1);
lcd.print(" Welcomes U ");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("ENTER PASS KEY");
lcd.setCursor(0,1);
for(int j=0;j<4;j++)
EEPROM.write(j, j+49);
for(int j=0;j<4;j++)
pass[j]=EEPROM.read(j);
}
void loop()
{
digitalWrite(11, HIGH);
customKey = customKeypad.getKey();
if(customKey=='#')
change();
if (customKey)
{
password[i++]=customKey;
lcd.print(customKey);
Serial.print(customKey);
beep();
delay(2000);
}
if(i==4)
{
delay(200);
for(int j=0;j<4;j++)
pass[j]=EEPROM.read(j);
if(!(strncmp(password, pass,4)))
{
digitalWrite(led, HIGH);
beep();
delay(200);
lcd.clear();
lcd.print("Passkey Accepted");
digitalWrite(11, LOW);
delay(4000);
lcd.setCursor(0,1);
lcd.print("#.Change Passkey");
delay(2000);
lcd.clear();
lcd.print("Enter Passkey: ");
lcd.setCursor(0,1);
i=0;
digitalWrite(led, LOW);
}
else
{
digitalWrite(11, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
lcd.clear();
lcd.print("Access Denied...");
lcd.setCursor(0,1);
lcd.print("#.Change Passkey");
delay(1000);
lcd.clear();
lcd.print("Enter Passkey:");
lcd.setCursor(0,1);
i=0;
digitalWrite(buzzer, LOW);
}
}
}
void change()
{
int j=0;
lcd.clear();
lcd.print("Current Passkey");
lcd.setCursor(0,1);
while(j<4)
{
char key=customKeypad.getKey();
if(key)
{
pass1[j++]=key;
lcd.print(key);
Serial.print(key);
beep();
}
key=0;
}
delay(500);

if((strncmp(pass1, pass, 4)))
{
lcd.clear();
lcd.print("Wrong Passkey...");
lcd.setCursor(0,1);
lcd.print("Better Luck Again");
delay(1000);
}
else
{
j=0;
lcd.clear();
lcd.print("Enter New Passk:");
lcd.setCursor(0,1);
while(j<4)
{
char key=customKeypad.getKey();
if(key)
{
pass[j]=key;
lcd.print(key);
Serial.print(key);
EEPROM.write(j,key);
j++;
beep();
}
}
lcd.print(" Done......");
delay(1000);
}
lcd.clear();
lcd.print("Enter Ur Passk:");
lcd.setCursor(0,1);
customKey=0;
}
void beep()
{
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
}

Video Tutorial:

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 508

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×