Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Arduino-Based Smart Lock System

Overview

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.

Circuit Diagram

Circuit Diagram

Features

  • 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 (press C) to correct typos before submission.

Hardware Components

  • Arduino Uno (ATmega328P MCU)
  • 16x2 LCD Display
  • 4x4 Matrix Keypad
  • Micro Servo Motor
  • Breadboard & Jumper Wires

Libraries Used

  • <Keypad.h> - For matrix keypad scanning.
  • <LiquidCrystal.h> - For LCD parallel interfacing.
  • <Servo.h> - For generating PWM signals to control the motor.

Pin Configuration (Hardware Setup)

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

How to Run the Simulation

You can test and view the circuit without any physical hardware using my Tinkercad simulation.

  1. Open the Tinkercad Simulation Link.
  2. Click Start Simulation.
  3. The master password defaults to A753.
  4. Try entering the wrong password 3 times to observe the non-blocking FSM countdown logic!

How to Run on Real Hardware

  1. Clone this repository to your local machine.
  2. Ensure you have the Keypad and Servo libraries installed in your Arduino IDE.
  3. Wire the components according to the Pin Configuration table above.
  4. Open Arduino-Smart-Lock.ino in the Arduino IDE.
  5. Compile and upload the code to your Arduino Uno.

Key Learnings

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages