High Security Keypad System
High Security Keypad System with employed audible alarm to alert security services.
Components and supplies
5 mm LED: Green
4x4 Keypad Module
Alphanumeric LCD, 16 x 2
Resistor 220 ohm
Buzzer, Piezo
Rotary potentiometer (generic)
Arduino UNO
DC Motor, 12 V
Apps and platforms
Arduino IDE
Tinkercad
Project description
Code
High Security Keypad System
c_cpp
1#include <LiquidCrystal.h> // Include LiquidCrystal library 2#include <Keypad.h> // Include Keypad library 3LiquidCrystal movie(A5,A4,A3,A2,A1,A0); 4#define Password_Length 8 // Length of password + 1 for null character 5char Data[Password_Length]; // Character to hold password input 6char Master[Password_Length] = "12A34B5"; // Password 7char customKey; // Character to hold key input 8int electric_motor = 10; // Pin connected to Electric Motor 9int buzzer = 11; // Pin connected to Buzzer 10int indicator_led = 12; // Pin connected to Green Indicator LED 11int k ; 12int i = 0; 13int s = 0; 14int g = 0; 15int a = 0; 16int wait = 300; // Delay time for LED 17byte data_count = 0; // Counter for character entries 18const byte ROWS = 4; // Constants for row sizes 19const byte COLS = 4; // Constants for column sizes 20 21char hexaKeys[ROWS][COLS] = { // Array to represent keys on keypad 22{'1', '2', '3', 'A'}, 23{'4', '5', '6', 'B'}, 24{'7', '8', '9', 'C'}, 25{'*', '0', '#', 'D'} 26}; 27 28byte rowPins[ROWS] = {9, 8, 7, 6}; // Connections to Arduino 29byte colPins[COLS] = {5, 4, 3, 2}; 30Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); // Create keypad object 31 32void setup() { 33 34 pinMode(electric_motor, OUTPUT); // Set Electric Motor pin as an OUTPUT pin 35 pinMode(buzzer, OUTPUT); // Set Buzzer pin as an OUTPUT pin 36 pinMode(indicator_led, OUTPUT); // Set Green Indicator LED pin as an OUTPUT pin 37 Serial.begin(9600); // Initialize serial communications at 9600 baud rate 38 movie.begin(16,2); // Initialize LiquidCrystal display 39 Serial.print("Enter Password:"); 40 movie.print("Enter Password:"); 41 delay(1500); 42 movie.clear(); 43 44} 45void loop() { 46 47 48for(k=0;k<7 && g<1;k++) // "For loop" for taking Input 49{ 50 movie.setCursor(0,0); 51 movie.print("Enter Password:"); 52 delay(100); 53 54 customKey = customKeypad.getKey(); // Look for keypress 55if (customKey) { // Enter keypress into array and increment counter 56 Data[data_count] = customKey; 57 Serial.print(Data[data_count]); 58 59 movie.setCursor(s,1); // LCD Command for changing the column of second row 60 movie.print(Data[data_count]); 61 62 digitalWrite(indicator_led,HIGH); // Blink the green indicator LED with every successful input 63 delay(wait); 64 digitalWrite(indicator_led,LOW); 65 delay(wait); 66 67 data_count++; 68 s++; 69} 70} 71 72 73if (data_count == Password_Length - 1) { // See if we have reached the password length 74 while(i<1) 75{ 76 Serial.println(""); // For sending the serial monitor's cursor in next line 77 movie.print(""); 78 i++; 79} 80 81 if (!strcmp(Data, Master)) { // Password is correct 82 83 digitalWrite(electric_motor, HIGH); 84 digitalWrite(buzzer, LOW); 85 Serial.println("correct"); 86 movie.clear(); 87 movie.setCursor(0,0); 88 movie.print("The password is"); 89 movie.setCursor(0,1); 90 movie.print("correct"); 91 delay(1000); 92 movie.clear(); 93 g=1; 94} 95else { 96 97 digitalWrite(electric_motor, LOW); // Password is incorrect 98 digitalWrite(buzzer,HIGH); 99 Serial.println("incorrect"); 100 movie.clear(); 101 movie.setCursor(0,0); 102 movie.print("The password is"); 103 movie.setCursor(0,1); 104 movie.print("incorrect"); 105 delay(1000); 106 movie.clear(); 107 g=1; 108} 109} 110 a=1; 111} 112void clearData() { 113while (data_count != 0) { // Go through array and clear data 114Data[data_count--] = 0; 115} 116return; 117} 118
High Security Keypad System
c_cpp
1#include <LiquidCrystal.h> // Include LiquidCrystal library 2#include 3 <Keypad.h> // Include Keypad library 4LiquidCrystal movie(A5,A4,A3,A2,A1,A0); 5#define 6 Password_Length 8 // Length of password + 1 for null character 7char Data[Password_Length]; 8 // Character to hold password input 9char Master[Password_Length] = "12A34B5"; 10 // Password 11char customKey; // Character to hold key input 12int electric_motor 13 = 10; // Pin connected to Electric Motor 14int buzzer = 11; // Pin connected 15 to Buzzer 16int indicator_led = 12; // Pin connected to Green Indicator LED 17int 18 k ; 19int i = 0; 20int s = 0; 21int g = 0; 22int a = 0; 23int wait = 300; // 24 Delay time for LED 25byte data_count = 0; // Counter for character entries 26const 27 byte ROWS = 4; // Constants for row sizes 28const byte COLS = 4; // Constants for 29 column sizes 30 31char hexaKeys[ROWS][COLS] = { // Array to represent keys on 32 keypad 33{'1', '2', '3', 'A'}, 34{'4', '5', '6', 'B'}, 35{'7', '8', '9', 'C'}, 36{'*', 37 '0', '#', 'D'} 38}; 39 40byte rowPins[ROWS] = {9, 8, 7, 6}; // Connections to 41 Arduino 42byte colPins[COLS] = {5, 4, 3, 2}; 43Keypad customKeypad = Keypad(makeKeymap(hexaKeys), 44 rowPins, colPins, ROWS, COLS); // Create keypad object 45 46void setup() { 47 48 49 pinMode(electric_motor, OUTPUT); // Set Electric Motor pin as an OUTPUT pin 50 51 pinMode(buzzer, OUTPUT); // Set Buzzer pin as an OUTPUT pin 52 pinMode(indicator_led, 53 OUTPUT); // Set Green Indicator LED pin as an OUTPUT pin 54 Serial.begin(9600); 55 // Initialize serial communications at 9600 baud rate 56 movie.begin(16,2); 57 // Initialize LiquidCrystal display 58 Serial.print("Enter Password:"); 59 60 movie.print("Enter Password:"); 61 delay(1500); 62 movie.clear(); 63 64} 65void 66 loop() { 67 68 69for(k=0;k<7 && g<1;k++) // "For loop" for taking 70 Input 71{ 72 movie.setCursor(0,0); 73 movie.print("Enter Password:"); 74 75 delay(100); 76 77 customKey = customKeypad.getKey(); // Look for keypress 78if 79 (customKey) { // Enter keypress into array and increment counter 80 81 Data[data_count] = customKey; 82 Serial.print(Data[data_count]); 83 84 movie.setCursor(s,1); 85 // LCD Command for changing the column of second row 86 movie.print(Data[data_count]); 87 88 89 digitalWrite(indicator_led,HIGH); // Blink the green indicator LED with 90 every successful input 91 delay(wait); 92 digitalWrite(indicator_led,LOW); 93 94 delay(wait); 95 96 data_count++; 97 s++; 98} 99} 100 101 102if (data_count 103 == Password_Length - 1) { // See if we have reached the password length 104 while(i<1) 105 106{ 107 Serial.println(""); // 108 For sending the serial monitor's cursor in next line 109 movie.print(""); 110 111 i++; 112} 113 114 if (!strcmp(Data, Master)) { // Password is correct 115 116 117 digitalWrite(electric_motor, HIGH); 118 digitalWrite(buzzer, LOW); 119 Serial.println("correct"); 120 121 movie.clear(); 122 movie.setCursor(0,0); 123 movie.print("The password is"); 124 125 movie.setCursor(0,1); 126 movie.print("correct"); 127 delay(1000); 128 129 movie.clear(); 130 g=1; 131} 132else { 133 134 digitalWrite(electric_motor, 135 LOW); // Password is incorrect 136 digitalWrite(buzzer,HIGH); 137 Serial.println("incorrect"); 138 139 movie.clear(); 140 movie.setCursor(0,0); 141 movie.print("The password is"); 142 143 movie.setCursor(0,1); 144 movie.print("incorrect"); 145 delay(1000); 146 147 movie.clear(); 148 g=1; 149} 150} 151 a=1; 152} 153void clearData() { 154while 155 (data_count != 0) { // Go through array and clear data 156Data[data_count--] 157 = 0; 158} 159return; 160} 161
Downloadable files
High Security Keypad System
When password is incorrect, this will be the project output.
High Security Keypad System

High Security Keypad System
When password is incorrect, this will be the project output.
High Security Keypad System

High Security Keypad System
When password is correct, this will be the project output.
High Security Keypad System

High Security Keypad System
This is the video of working project
High Security Keypad System
High Security Keypad System
When password is incorrect, this will be the project output.
High Security Keypad System

Comments
Only logged in users can leave comments