Password Based Door Lock Security System Using Arduino
Introduction
In This Tutorial, we will show the keypad-based security system. this system is required for our home or office so that no one can access the room without our permission and ensure protection against theft or loss of our important accessories and assets.
so let’s do the project, Arduino keypad-based door look which can be mounted to any of your existing doors to secure them with a digital password.
if you interested in more Arduino Tutorial
Bill of Materials
These all are components needed to make the Project
S.N | Component | Quantity | Link To Buy |
1 | Arduino nano | 1 | |
2 | 16x2 LCD Display | 1 | |
3 | 10k Pot | 1 | |
4 | SG-90 Servo motor | 1 | |
5 | 4x4 Keypad | 1 | |
6 | Buzzer | 1 | |
7 | Zero PCB | 1 | |
8 | 12v Power Supply | 1 |
Circuit diagram
Now we connected all the Components. the Arduino board is the brain of our project hey controls all things.16×2 LCD Display will be connected to the Arduino when turning on the system first welcome message will display on the LCD.
In this project, we used the 4×4 matrix Keypad we need to password input manually to unlock our customized door locker.
Source CodeĀ
Now we upload the code but wait, first, you add the few libraries first then you upload the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
#include <Keypad.h> #include <LiquidCrystal.h> #include <Servo.h> Servo myservo; int pos = 0; LiquidCrystal lcd(12, 11, 10, 9, 8, 7); const byte rows = 4; const byte cols = 4; char key[rows][cols] = { { '1', '2', '3' }, { '4', '5', '6' }, { '7', '8', '9' }, { '*', '0', '#' } }; byte rowPins[rows] = { A0, A1, A2, A3 }; byte colPins[cols] = { A4, A5, A6, A7 }; Keypad keypad = Keypad(makeKeymap(key), rowPins, colPins, rows, cols); char* password = "4567"; int currentposition = 0; int redled = 6; int greenled = 5; int buzz = 4; int invalidcount = 12; void setup() { displayscreen(); Serial.begin(9600); pinMode(redled, OUTPUT); pinMode(greenled, OUTPUT); pinMode(buzz, OUTPUT); myservo.attach(4); lcd.begin(16, 2); } void loop() { if (currentposition == 0) { displayscreen(); } int l; char code = keypad.getKey(); if (code != NO_KEY) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("PASSWORD:"); lcd.setCursor(7, 1); lcd.print(" "); lcd.setCursor(7, 1); for (l = 0; l <= currentposition; ++l) { lcd.print("*"); keypress(); } if (code == password[currentposition]) { ++currentposition; if (currentposition == 4) { unlockdoor(); currentposition = 0; } } else { ++invalidcount; incorrect(); currentposition = 0; } if (invalidcount == 5) { ++invalidcount; torture1(); } if (invalidcount == 8) { torture2(); } } } void unlockdoor() { delay(900); lcd.setCursor(0, 0); lcd.println(" "); lcd.setCursor(1, 0); lcd.print("Access Granted"); lcd.setCursor(4, 1); lcd.println("WELCOME!!"); lcd.setCursor(15, 1); lcd.println(" "); lcd.setCursor(16, 1); lcd.println(" "); lcd.setCursor(14, 1); lcd.println(" "); lcd.setCursor(13, 1); lcd.println(" "); unlockbuzz(); for (pos = 180; pos >= 0; pos -= 5) { myservo.write(pos); delay(5); } delay(2000); counterbeep(); delay(1000); for (pos = 0; pos <= 180; pos += 5) { myservo.write(pos); delay(15); currentposition = 0; lcd.clear(); displayscreen(); } } void incorrect() { delay(500); lcd.clear(); lcd.setCursor(1, 0); lcd.print("CODE"); lcd.setCursor(6, 0); lcd.print("INCORRECT"); lcd.setCursor(15, 1); lcd.println(" "); lcd.setCursor(4, 1); lcd.println("GET AWAY!!!"); lcd.setCursor(13, 1); lcd.println(" "); Serial.println("CODE INCORRECT YOU ARE UNAUTHORIZED"); digitalWrite(redled, HIGH); digitalWrite(buzz, HIGH); delay(3000); lcd.clear(); digitalWrite(redled, LOW); digitalWrite(buzz, LOW); displayscreen(); } void clearscreen() { lcd.setCursor(0, 0); lcd.println(" "); lcd.setCursor(0, 1); lcd.println(" "); lcd.setCursor(0, 2); lcd.println(" "); lcd.setCursor(0, 3); lcd.println(" "); } void keypress() { digitalWrite(buzz, HIGH); delay(50); digitalWrite(buzz, LOW); } void displayscreen() { lcd.setCursor(0, 0); lcd.println("*ENTER THE CODE*"); lcd.setCursor(1, 1); lcd.println("TO _/_ (OPEN)!!"); } void armservo() { for (pos = 180; pos <= 180; pos += 50) { myservo.write(pos); delay(5); } delay(5000); for (pos = 180; pos >= 0; pos -= 50) { myservo.write(pos); } } void unlockbuzz() { digitalWrite(buzz, HIGH); delay(80); digitalWrite(buzz, LOW); delay(80); digitalWrite(buzz, HIGH); delay(80); digitalWrite(buzz, LOW); delay(200); digitalWrite(buzz, HIGH); delay(80); digitalWrite(buzz, LOW); delay(80); digitalWrite(buzz, HIGH); delay(80); digitalWrite(buzz, LOW); delay(80); } void counterbeep() { delay(1200); lcd.clear(); digitalWrite(buzz, HIGH); lcd.setCursor(2, 15); lcd.println(" "); lcd.setCursor(2, 14); lcd.println(" "); lcd.setCursor(2, 0); delay(200); lcd.println("GET IN WITHIN:::"); lcd.setCursor(4, 1); lcd.print("5"); delay(200); lcd.clear(); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN:"); digitalWrite(buzz, LOW); delay(1000); digitalWrite(buzz, HIGH); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN:"); lcd.setCursor(4, 1); lcd.print("4"); delay(100); lcd.clear(); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN:"); digitalWrite(buzz, LOW); delay(1000); digitalWrite(buzz, HIGH); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN:"); lcd.setCursor(4, 1); //3 lcd.print("3"); delay(100); lcd.clear(); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN:"); digitalWrite(buzz, LOW); delay(1000); digitalWrite(buzz, HIGH); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN:"); lcd.setCursor(4, 1); //4 lcd.print("2"); delay(100); lcd.clear(); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN:"); digitalWrite(buzz, LOW); delay(1000); digitalWrite(buzz, HIGH); lcd.setCursor(4, 1); lcd.print("1"); delay(100); lcd.clear(); lcd.setCursor(2, 0); lcd.println("GET IN WITHIN::"); digitalWrite(buzz, LOW); delay(1000); //5 digitalWrite(buzz, HIGH); delay(40); digitalWrite(buzz, LOW); delay(40); digitalWrite(buzz, HIGH); delay(40); digitalWrite(buzz, LOW); delay(40); digitalWrite(buzz, HIGH); delay(40); digitalWrite(buzz, LOW); delay(40); digitalWrite(buzz, HIGH); delay(40); digitalWrite(buzz, LOW); lcd.clear(); lcd.setCursor(2, 0); lcd.print("RE-LOCKING"); delay(500); lcd.setCursor(12, 0); lcd.print("."); delay(500); lcd.setCursor(13, 0); lcd.print("."); delay(500); lcd.setCursor(14, 0); lcd.print("."); delay(400); lcd.clear(); lcd.setCursor(4, 0); lcd.print("LOCKED!"); delay(440); } void torture1() { delay(1000); lcd.clear(); lcd.setCursor(2, 0); lcd.print("WAIT FOR "); lcd.setCursor(5, 1); lcd.print("15 SECONDS"); digitalWrite(buzz, HIGH); delay(15000); digitalWrite(buzz, LOW); lcd.clear(); lcd.setCursor(2, 0); lcd.print("LOL.."); lcd.setCursor(1, 1); lcd.print(" HOW WAS THAT??"); delay(3500); lcd.clear(); } void torture2() { delay(1000); lcd.setCursor(1, 0); lcd.print(" "); lcd.setCursor(2, 0); lcd.print("EAR DRUMS ARE"); lcd.setCursor(0, 1); lcd.print(" PRECIOUS!! "); delay(1500); lcd.clear(); lcd.setCursor(1, 0); lcd.print(" WAIT FOR"); lcd.setCursor(4, 1); lcd.print(" 1 MINUTE"); digitalWrite(buzz, HIGH); delay(55000); counterbeep(); lcd.clear(); digitalWrite(buzz, LOW); lcd.setCursor(2, 0); lcd.print("WANT ME TO"); lcd.setCursor(1, 1); lcd.print("REDICULE MORE??"); delay(2500); lcd.clear(); lcd.setCursor(2, 0); lcd.print("Ha Ha Ha Ha"); delay(1700); lcd.clear(); } |
Demo Of Projects
Ok, we just type the Password with the help of the 4×4 matrix keypad “4567” then the LCD Will Display The * sign if you want to change the passcode then you change in a code.
If the passcode is correct then LCD Display the Access Granted Message will Display and if the passcode in not correct then LCD Display the Passcode No Match Plz Try Again.