Background Research

My project is called “Arduino Password Lock Security System With Servo”. It is a password lock door security system that will add more security to your door in a very unique and creative way. This project works with Arduino UNO board, which is a software company, project, and user community that designs and manufactures computer open-source hardware, open-source software, and microcontroller-based kits for building digital devices and interactive objects that can sense and control physical devices. This is a project for all audience because there is no age requirement to accomplish this project. This innovating and creative project challenges all the audience to push themselves further into electronics. This password unlocks door security system can help students interested in engineering to know more about Arduino. In addition, Arduino uses a simplified version of C++, making it easier to learn to program. Finally, Arduino provides a standard form factor that breaks out the functions of the microcontroller into a more accessible package. Arduino is a great way to learn and understand programming in the easiest way.

Usage of Device:

pass[6] – is the array used to save and hold the user defined password.

check[6] – is the array used to collect & hold user input. This user input data (in check[] array) is compared with pass[] array to authenticate password.

entry – is the variable used to identify initial entry point of the program. User is asked to SET a 5 Digit Password at installation of Lock. Hence we need a variable to identify entry and loop 5 times to collect 5 digits and save them to pass[] array. The same variable is later made use of to Change Password. When the key for Changing Password (here ‘C’) is pressed, this variable is simply assigned a zero value (the initial state of variable). This forces the program control to re enter the Password Setting Loop of the program.

key_id – is the variable used to identify a key press and perform some actions in the program (that should happen only on a key press). By default this variable is set zero initial value. Whenever a key is pressed in keypad, this variable will be assigned a value =1. You may check the keyscan() function to see this. This simple trick helps to identify a key press and perform various actions on that key press (based on the value of key press). This variable is set to zero at different points in the program (to prevent the value 1 in key_id variable being identified as a false key press). You may check them as well.

Note:- col_scan – is the actual variable that gets activated to a LOW on key press (hence helps in identifying key press). But this variable is actually a part of the keypad interfacing program (version 2).

count – is the variable used to iterate the index of check[count] ( user input array ). count variable is initialized to 1. Each user input will be saved to check[] array in order of the increment of count variable.

temp_press – is a temporary variable to hold the value of key press. The value of key press is assigned to temp_press variable as a return result of the keypress() function. keypress() is the function defined to identify value of key press.

lcd_count – is a simple counter variable used to iterate the column position of LCD module. This variable helps to display user input data successively in row 2 of LCD module.

i,j,flag – are just dummy variables used in the program. i,j are used as counter variables inside for loop. flag is used to hold status of checkPassword() subroutine (the function used to compare user input data and the SET password ). A decision is made based on the value inside flag variable.

Program.

#include <Servo.h> #include <Keypad.h> Servo ServoMotor; char* password = "159"; // change the password here, just pick any 3 numbers int position = 0; 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] = { 8, 7, 6, 9 }; byte colPins[COLS] = { 5, 4, 3, 2 }; Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); int RedpinLock = 12; int GreenpinUnlock = 13; void setup() { pinMode(RedpinLock, OUTPUT); pinMode(GreenpinUnlock, OUTPUT); ServoMotor.attach(11); LockedPosition(true); } void loop() { char key = keypad.getKey(); if (key == '*' || key == '#') { position = 0; LockedPosition(true); } if (key == password[position]) { position ++; } if (position == 3) { LockedPosition(false); } delay(100); } void LockedPosition(int locked) { if (locked) { digitalWrite(RedpinLock, HIGH); digitalWrite(GreenpinUnlock, LOW); ServoMotor.write(11); } else { digitalWrite(RedpinLock, LOW); digitalWrite(GreenpinUnlock, HIGH); ServoMotor.write(90); } }