Manaois - Bsee3d - Doorlocking System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

NAME: ETHAN ZACHARY A.

MANAOIS DATE: 4/12/2024


SECTION: BSEE-3D SUBMITTED TO: ENGR. GILFRED ALLEN
MADRIGAL

Laboratory Activity 3: Door Locking System using Arduino Uno

Introduction:

The advent of embedded systems has revolutionized various aspects of our


lives, including security measures in residential and commercial buildings. In this
laboratory activity, we delve into the design and simulation of a door locking
system utilizing Arduino microcontroller and Proteus simulation software. The
system comprises a keypad for password entry, a servo motor for controlling the
door lock, and an LCD display for user interaction.

Embedded systems play a pivotal role in modern security solutions,


offering a combination of hardware and software components tailored to meet
specific requirements. The integration of Arduino microcontrollers provides a
flexible platform for developing custom security applications, enabling seamless
interaction between various peripherals.

Proteus simulation software offers a robust environment for testing and


validating embedded systems designs before deployment in real-world scenarios.
By simulating the door locking system, we can evaluate its functionality,
performance, and reliability without the need for physical hardware
components. This approach significantly reduces development time and costs
while facilitating iterative design improvements.

The keypad serves as the primary user interface for the door locking system,
allowing authorized
users to input their password securely. Keypad-based authentication is widely
adopted in access control systems due to its simplicity and effectiveness in
preventing unauthorized access.

The servo motor is employed to actuate the door lock mechanism based on
the input received from the keypad. Servo motors offer precise control over
angular displacement, making them ideal for applications requiring rotational
motion, such as door locks.
The LCD display enhances user interaction by providing feedback on the
system's status, including password entry prompts, error messages, and
confirmation messages upon successful authentication. Visual feedback is
essential for ensuring a smooth user experience and troubleshooting potential
issues.

Objectives:

After successful completion of this activity, student should be able to:

· Comprehend the integration of hardware components, such as keypad,


servo motor, and LCD display, with Arduino microcontroller to develop a
functional door locking system.
· Implement a user authentication mechanism using a keypad for password
entry and LCD display for user feedback, ensuring secure access control in
the simulated door locking system.
· Develop skills in troubleshooting and debugging embedded systems by
analyzing simulation results and identifying potential errors or
malfunctions.

Equipment Required:

Computer withArduino IDE installed

Computer with Proteus simulation software

Arduino Uno Microcontroller

Keypad

16x2 LCD display

Servo Motor

Power supply

Procedures:

1. Set up the Proteus simulation environment by launching the software and


creating a new project.

2. Drag and drop the required components onto the workspace, including
Arduino Uno, keypad, servo motor, and LCD display.
3. Connect the components according to the schematic diagram
provided in the project specifications, ensuring proper wiring
and connections.
4. Write the Arduino code to implement the functionality of the door
locking system, including keypad input, servo motor control, LCD display
interaction, password verification, and error handling.
5. Configure theArduino IDE settings to compile the code for the
Arduino Uno board.
6. Compile the Arduino code to check for any syntax errors or
compilation issues.
7. Generate the HEX file from the compiled code by selecting the
appropriate option in the Arduino IDE.
8. Upload the generated HEX file to the Arduino Uno board using the Proteus
software, ensuring proper configuration of the upload settings.
9. Set the simulation parameters in Proteus, such as simulation duration and
sampling rate, to match the desired testing conditions.
10. Run the simulation to verify the functionality of the door locking system,
observing the behavior of the keypad, servo motor, and LCD display.
11. Test various scenarios, including successful password entry, incorrect
password attempts, and error handling, to evaluate the system's
performance and reliability.
12. Analyze the simulation results and make any necessary adjustments to
the circuit design or Arduino code to optimize system functionality.
13. Document the simulation setup, including circuit diagram, Arduino code,
simulation parameters, and observations, in a comprehensive report for
future reference.
Example Source Codes:

#include <LiquidCrystal.h>
#include <Servo.h>
#include <Keypad.h>

Servo myservo;
int pos = 0; // position of servo motor
LiquidCrystal lcd(A4, A5, A3, A2, A1, A0);
const byte rows = 4;
const byte cols = 3;

char key[rows][cols] = {
{ '1', '2', '3' },
{ '4', '5', '6' },
{ '7', '8', '9' },
{ '*', '0', '#' }
};
byte rowPins[rows] = { 0, 1, 2, 3 };
byte colPins[cols] = { 4, 5, 6 };
Keypad keypad = Keypad(makeKeymap(key), rowPins, colPins, rows, cols);
char* password = "0123";
int currentposition = 0;

void setup() {

displayscreen();
//Serial.begin(9600);
myservo.attach(9); //Servo motor connection

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 {
incorrect();
currentposition = 0;
}
}
}

//------------------ Function 1- OPEN THE DOOR--------------//

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(" ");

for (pos = 180; pos >= 0; pos -= 5) // open the door


{
myservo.write(pos);
delay(5);
}
delay(2000);
delay(1000);
counterbeep();

delay(1000);

for (pos = 0; pos <= 180; pos += 5) // close the door


{ // in steps of 1 degree
myservo.write(pos);
delay(15);

currentposition = 0;

lcd.clear();
displayscreen();
}
}

//--------------------Function 2- Wrong code--------------//

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");
delay(3000);
lcd.clear();
displayscreen();
}
//-------Function 3 - CLEAR THE SCREEN--------------------/
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(" ");
}

//------------Function 4 - DISPLAY FUNCTION--------------------//


void displayscreen() {
lcd.setCursor(0, 0);
lcd.println("*ENTER THE CODE*");
lcd.setCursor(1, 1);

lcd.println("TO OPEN DOOR!!");


}

//--------------Function 5 - Count down------------------//


void counterbeep() {
delay(1200);

lcd.clear();

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:");
delay(1000);
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1); //2
lcd.print("4");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
delay(1000);

lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1);
lcd.print("3");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
delay(1000);

lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1);
lcd.print("2");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
delay(1000);

lcd.setCursor(4, 1);
lcd.print("1");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN::");

delay(1000);
delay(40);
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);
}
Simulation Environment:
OFF STATE

ON STATE
LOCKED STATE

UNLOCKED STATE
Conclusion:

TO CONCLUDE, THIS ACTIVITY HELPS US STUDENTS UNDERSTAND EMBEDDED


SYSTEMS DEVELOPMENT. I'VE GAINED VIRTUAL EXPERIENCE CONSTRUCTING
OPERATIONAL SYSTEMS BY INTEGRATING HARDWARE COMPONENTS SUCH AS THE
KEYPAD, SERVO MOTOR, AND LCD WITH THE ARDUINO MICROCONTROLLER. CREATING A
USER AUTHENTICATION MECHANISM USING THE KEYPAD FOR PASSWORD INPUT AND THE
LCD FOR FEEDBACK HAS ENRICHED OUR KNOWLEDGE ABOUT SECURE ACCESS CONTROL.

FURTHERMORE, THE FOCUS ON TROUBLESHOOTING AND DEBUGGING SHOWS


SIGNIFICANCE WHEN CREATING A CIRCUIT. ANALYZING SIMULATION RESULTS AND
IDENTIFYING POTENTIAL ERRORS HAS HONED MY PROBLEM-SOLVING ABILITIES, WHICH
WILL HELP US IN OUR FUTURE ENDEAVORS. OVERALL, THIS ACTIVITY HAS FURNISHED ME
WITH THEORETICAL AND PRACTICAL KNOWLEDGE, ENSURING I LEARNED NEW
KNOWLEDGE TO DESIGN AND MAINTAIN EMBEDDED SYSTEMS EFFECTIVELY.
Questions to answer:

1. Describe the role of the keypad in the door locking system. How does it
facilitate user interaction and enable authentication?
THE KEYPAD ON THE DOOR LOCKING SYSTEM SERVES AS THE PRIMARY INTERFACE
FOR USER INTERACTION AND AUTHENTICATION. USERS ENTER THEIR ACCESS CODES
USING THE KEYPAD'S NUMERIC KEYS. THE SYSTEM CHECKS THIS CODE TO
PREVIOUSLY STORED PERMITTED CODES TO GIVE OR DENY ACCESS. IN ADDITION,
THE KEYPAD GIVES USERS WITH FEEDBACK, USUALLY IN THE FORM OF VISUAL
INDICATIONS, TO GUIDE THEM THROUGH THE AUTHENTICATION PROCESS. OVERALL,
THE KEYPAD IS CRITICAL TO PROVIDING SAFE ACCESS CONTROL AND ALLOWING USER
ENGAGEMENT IN THE SYSTEM.

2. Explain the significance of using a servo motor in the door locking


system. How does it contribute to the physical actuation of the lock
mechanism?
THE DOOR LOCKING SYSTEM'S SERVO MOTOR PERFECTLY ENGAGES THE
LOCK MECHANISM, GUARANTEEING DEPENDABLE LOCKING AND
UNLOCKING. IT SMOOTHLY INTERACTS WITH THE CONTROL SYSTEM, OFFERS
CONTROLLED MOVEMENT VIA A MECHANICAL CONNECTION, AND IMPROVES
SECURITY BY MAKING IT MORE DIFFICULT FOR UNAUTHORIZED ENTRY.
3. Discuss the importance of error handling in the door locking system. How are
errors detected and managed to maintain system security?
FOR THE DOOR LOCKING SYSTEM TO REMAIN FUNCTIONAL AND SECURE, ERROR
MANAGEMENT IS ESSENTIAL. IT ENTAILS ERROR MANAGEMENT AND DETECTION TO
STOP UNWANTED ACCESS AND SYSTEM FAILURE. ROBUST EXCEPTION HANDLING,
FEEDBACK SYSTEMS, SENSOR MONITORING, AND INPUT VALIDATION ARE USED TO
ACCOMPLISH THIS. EFFICIENT MANAGEMENT OF ERRORS GUARANTEES THE
SYSTEM'S DEPENDABILITY AND SECURITY IN A RANGE OF SCENARIOS.
4. If the servo motor exhibits erratic behavior, such as partial movements or
jittering, during the unlocking process, what potential factors could
contribute to this issue, and how would you troubleshoot and resolve it?
POTENTIAL REASONS OF INCONSISTENT BEHAVIOR IN THE SERVO MOTOR
DURING UNLOCKING INCLUDE OVERLOAD, OVERHEATING, MECHANICAL
BLOCKAGES, WIRING DIFFICULTIES, AND PROBLEMS WITH THE POWER SUPPLY. TO
SOLVE THE PROBLEM, LOWER THE LOAD, CALIBRATE THE SERVO MOTOR,
EXAMINE MECHANICAL PARTS, CONFIRM WIRE CONNECTIONS, AND CHECK THE
STABILITY OF THE POWER SUPPLY. ISOLATING THE PROBLEM FOR REPAIR CAN BE
AIDED BY TESTING IN A CONTROLLED SETTING.
5. Suppose the door locking system experiences sporadic instances of
incorrect password recognition, leading to unauthorized access. How would
you troubleshoot this security breach, and what measures would you
implement to enhance password validation and prevent further
unauthorized entries?
To stop illegal access and solve occasionally inaccurate password recognition:
1. Examine the code for correctness of validation.
2. Put strong input validation in place.
3. Improve error handling so that feedback is obvious.
4. Safely encrypt passwords that are saved.
5. Make sure passwords are difficult and changed often.
6. Use rate-limiting techniques to stop brute-force assaults.
7. Keep audit logs up to date for oversight and monitoring.

References:
Virtual Engineer. (2020, Oct. 8). Password Based Door Locking System Using
Arduino // Proteus Simulation
https://www.youtube.com/watch?v=HpBvUFPhB-I&list=LL&index=1&t=554s

You might also like