Access Control System
Access Control System
submitted by
M.Subbu Lakshmi:953023104121
S.Muthu Shivani:953023104077
M.pon Aparna :953023104084
M.Navanitha :953023104079
M.Priya Dharshini:953023104094
BACHELOR OF ENGINEERING
IN
MAY 2025
ACKNOWLEDGEMENT
Abstract
introduction
system overview
Circuit components
Arduino code
How to use
Conclusion
Abstract
Door lock systems are a crucial aspect of securing buildings, rooms, and other
areas. Traditional lock systems rely on physical keys, which can be lost, stolen,
or copied. Modern electronic access control methods offer a more secure and
convenient alternative. This project simulates a door lock system using an
Arduino Uno, a servo motor, and a keypad, providing a basic example of
electronic access control. By leveraging the capabilities of Arduino and keypad
technology, this project demonstrates a fundamental approach to access
control, paving the way for more complex and sophisticated systems. The
project's outcomes highlight the potential of electronic access control systems
in various settings, including residential, commercial, and industrial
environments.
System Overview
1. *Arduino Uno (Core Controller)*: The Arduino Uno serves as the brain of the
system, processing user input from the keypad and controlling the servo
motor.
2. *Keypad (User Input)*: The keypad allows users to enter a password, which is
then verified by the Arduino Uno.
3. *Servo Motor (Door Lock Mechanism)*: The servo motor simulates the door
lock mechanism, unlocking the door when the correct password is entered.
4. *Simulated Door Lock (Output)*: The simulated door lock represents the
output of the system, providing a visual representation of the door's locked or
unlocked state.
This system provides a basic example of electronic access control and can be
enhanced for various applications, such as adding multiple users,
implementing password changes, or integrating with other security systems.
System Overview
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'} // Fixed the keypad definition
};
Servo servo;
int servoPin = 10;
String password = "1234";
String input = "";
void setup() {
Serial.begin(9600);
servo.attach(servoPin);
servo.write(0); // Lock the door initially
}
void loop() {
// Handle keypad input
char key = keypad.getKey();
if (key) {
if (key == '#') {
if (input == password) {
Serial.println("Correct password! Unlocking door...");
servo.write(90); // Unlock the door
unlockStartTime = millis(); // Record unlock time
doorUnlocked = true;
} else {
Serial.println("Incorrect password! Try again.");
}
input = ""; // Clear input after '#'
} else if (key == '*') { // Example: Add a clear input key
input = "";
Serial.println("\nInput cleared.");
}
else {
input += key;
Serial.print("*");
}
}
2. Keypad Configuration:
- `const int ROW_NUM = 4;`: Defines the number of rows on the
keypad (4).
- `const int COLUMN_NUM = 4;`: Defines the number of columns on
the keypad (4).
- `char keys[ROW_NUM][COLUMN_NUM] = { ... };`: This 2D array
maps the physical layout of your 4x4 keypad to the characters that
each key represents. For example, `{'1','2','3','A'}` represents the top
row.
- `byte pin_rows[ROW_NUM] = {9, 8, 7, 6};`: An array specifying the
Arduino digital pins connected to the rows of the keypad.
- `byte pin_column[COLUMN_NUM] = {5, 4, 3, 2};`: An array
specifying the Arduino digital pins connected to the columns of the
keypad.
- `Keypad keypad = Keypad(makeKeymap(keys), pin_rows,
pin_column, ROW_NUM, COLUMN_NUM);`: This line creates an
instance of the `Keypad` object, initializing it with the key mapping,
row pins, column pins, and dimensions of the keypad. This object
will be used to get key presses.
3. Servo & Logic Variables:
- `Servo servo;`: Declares a `Servo` object, which will be
used to control the physical servo motor.
- `int servoPin = 10;`: Defines the Arduino digital pin to
which the servo's data line is connected (Pin 10).
- `String password = "1234";`: Stores the predefined
password that needs to be entered to unlock the "door". This
is a hardcoded password.
- `String input = "";`: A string variable used to accumulate
the characters entered by the user on the keypad before
checking the password.
- `unsigned long unlockStartTime = 0;`: (From the enhanced
version) A variable to store the `millis()` value when the door
is unlocked, used for timing the unlock duration.
- `const long unlockDuration = 5000;`: (From the enhanced
version) Defines the duration (in milliseconds, 5 seconds) for
which the door remains unlocked.
- `bool doorUnlocked = false;`: (From the enhanced version)
A boolean flag to track the current state of the door (locked
or unlocked).
4. `setup()` Function:
- `void setup() { ... }`: This function runs only once when the
Arduino board starts or resets.
- `Serial.begin(9600);`: Initializes serial communication at a
baud rate of 9600. This is crucial for printing messages to
the Serial Monitor for debugging and user feedback.
- `servo.attach(servoPin);`: Attaches the `Servo` object to
the specified `servoPin` (Pin 10). This tells the Arduino to
prepare that pin to control a servo.
- `servo.write(0);`: Sets the initial position of the servo to 0
degrees, simulating a "locked" state.
5. `loop()` Function:
- `void loop() { ... }`: This function runs repeatedly, endlessly, after the `setup()`
function completes. It's the heart of the program's logic.
- `char key = keypad.getKey();`: This is the core of the keypad interaction. It
checks if any key has been pressed and released. If a key is pressed, it returns the
character mapped to that key; otherwise, it returns 0.
- `if (key) { ... }`: This `if` block executes only when a key is pressed.
- `if (key == '#') { ... }`: Checks if the pressed key is the '#' key. This key acts as the
"Enter" or "Submit" key for the password.
- `if (input == password) { ... }`: Compares the accumulated `input` string with
the predefined `password`.
- `Serial.println("Correct password! Unlocking door...");`: Prints a success
message to the Serial Monitor.
- `servo.write(90);`: Moves the servo to 90 degrees, simulating an "unlocked"
state.
- `unlockStartTime = millis();`: (Enhanced version) Records the current time to
start the unlock timer.
- `doorUnlocked = true;`: (Enhanced version) Sets the flag to indicate the door
is unlocked.
- `else { ... }`: If the `input` does not match the `password`.
- `Serial.println("Incorrect password! Try again.");`: Prints an error message.
- `input = "";`: Clears the `input` string, whether the password was correct or
not, preparing for the next attempt.
- `else if (key == '*') { ... }`: (Enhanced version) Checks if the pressed key is the '*'
key (used as a clear/reset key).
- `input = "";`: Clears the accumulated input.
- `Serial.println("\nInput cleared.");`: Provides feedback that the input has
been cleared.
- `else { ... }`: If the pressed key is *not* '#' or '*', it means it's a digit or another
character to be part of the password.
- `input += key;`: Appends the pressed key character to the `input` string.
- `Serial.print("*");`: Prints an asterisk to the Serial Monitor for masking the
input.
- `if (doorUnlocked && (millis() - unlockStartTime >= unlockDuration)) { ... }`:
(From the enhanced version) This block continuously checks if the door is
currently unlocked (`doorUnlocked` is true) AND if the `unlockDuration` has
passed since `unlockStartTime`.
- `Serial.println("Locking door...");`: Prints a message indicating the door is being
relocked.
- `servo.write(0);`: Moves the servo back to 0 degrees (locked state).
- `doorUnlocked = false;`: Resets the flag to indicate the door is now locked.
How to use
Step-by-Step Instructions
1. *Enter the Password*: Enter the password "1234" using the keypad. As you enter
each digit, an asterisk (*) will appear in the serial monitor to mask the password.
2. *Submit the Password*: After entering the password, press the "#" key to submit
it. The Arduino Uno will then verify the password.
3. *Password Verification*: If the password is correct, the serial monitor will display
"Correct password! Unlocking door...". The servo motor will then rotate to the 90-
degree position, simulating the unlocking of the door.
4. *Door Unlocking*: The door will remain unlocked for 5 seconds, allowing access.
5. *Door Locking*: After 5 seconds, the servo motor will rotate back to the 0-
degree position, simulating the locking of the door.
6. *Incorrect Password*: If the password is incorrect, the serial monitor will display
"Incorrect password! Try again.". The door will remain locked.
- Make sure to enter the correct password to avoid multiple incorrect attempts.
- The door will only remain unlocked for 5 seconds. If you need more time, you will
need to re-enter the password and submit it again.
- You can modify the password and other parameters in the Arduino code to suit
your needs.
System Limitations
- The system uses a simple password verification mechanism and may not be
suitable for high-security applications.
- The system assumes that the user will enter the correct password. You may want
to add additional features, such as a limited number of attempts or a timeout
period, to enhance security.
By following these steps and understanding the system's limitations, you can
effectively use the door lock system to simulate electronic access control using an
Arduino Uno, servo motor, and keypad.
conclusion
this project demonstrates a basic door lock system using an
Arduino Uno, a servo motor, and a keypad. The system
provides a simple example of electronic access control and
showcases the potential of Arduino-based systems in security
applications. The Wokwi simulator allows for easy testing and
modification of the project, making it an ideal platform for
experimenting with Arduino-based systems.