This project is an embedded access control prototype built using an Arduino Uno (ATmega328P). It utilizes a 4x4 matrix keypad for password entry, a 16x2 LCD for user interface, and a servo motor for the locking mechanism.
Instead of using basic blocking delay() functions, the firmware is architected using a Finite State Machine (FSM) and non-blocking timers (millis()). This ensures the microcontroller remains continuously responsive to user inputs and enables dynamic features like a live LCD countdown timer.
- Finite State Machine (FSM): Structured firmware logic to manage system states (Boot, Locked, Input, Evaluate, Unlocked, Lockout) without freezing the CPU.
- Anti-Brute-Force Lockout: Tracks consecutive failed attempts. After 3 incorrect entries, the system securely locks out all inputs for 10 seconds and displays a live, non-blocking countdown on the LCD.
- Data Security & Memory Safety: Utilizes proper C-string handling, including explicit null-termination and memory clearing (
memset) to prevent buffer vulnerabilities. - User Experience: Real-time UI password masking (displays
*as the user types) and a clear function (pressC) to correct typos before submission.
- Arduino Uno (ATmega328P MCU)
- 16x2 LCD Display
- 4x4 Matrix Keypad
- Micro Servo Motor
- Breadboard & Jumper Wires
<Keypad.h>- For matrix keypad scanning.<LiquidCrystal.h>- For LCD parallel interfacing.<Servo.h>- For generating PWM signals to control the motor.
| Component | Arduino Pin |
|---|---|
| Servo Motor | D10 (PWM) |
| LCD RS | A0 |
| LCD EN | A1 |
| LCD D4 - D7 | A2, A3, A4, A5 |
| Keypad Rows (1-4) | D0, D1, D2, D3 |
| Keypad Cols (1-4) | D4, D5, D6, D7 |
You can test and view the circuit without any physical hardware using my Tinkercad simulation.
- Open the Tinkercad Simulation Link.
- Click Start Simulation.
- The master password defaults to A753.
- Try entering the wrong password 3 times to observe the non-blocking FSM countdown logic!
- Clone this repository to your local machine.
- Ensure you have the
KeypadandServolibraries installed in your Arduino IDE. - Wire the components according to the Pin Configuration table above.
- Open
Arduino-Smart-Lock.inoin the Arduino IDE. - Compile and upload the code to your Arduino Uno.
This project served as a practical learning exercise to transition from basic Arduino scripting to writing structured embedded C++ firmware. It reinforced the importance of CPU time management (replacing delays with hardware timers) and safe memory practices in resource-constrained environments.
