Want to build a working Arduino password door lock from scratch? In this step-by-step tutorial, you will wire a 4×4 matrix keypad, a 16×2 I2C LCD display, and an SG90 servo motor to an Arduino Uno to create a fully functional electronic door lock. Essentially, the keypad captures your password, the LCD gives real-time feedback, and the servo physically locks or unlocks the door. Whether you are learning Arduino for the first time or building a DIY security project for your home or makerspace, this Arduino keypad door lock tutorial covers everything you need: wiring, full code, a line-by-line code breakdown, testing tips, and upgrade ideas.
ما ستتعلمه
By the end of this Arduino password lock with LCD tutorial, you will understand:
- The way the 4×4 matrix keypad sends password input to Arduino.
- What role the I2C LCD plays in providing real-time user feedback (prompts, masked input, error messages).
- How the servo motor simulates a physical lock/unlock mechanism.
- The way the password-check logic works in the Arduino sketch.
- Steps to test, calibrate, and troubleshoot the complete system.
- Ways to customize and upgrade the project for a real door enclosure or smart home setup.
How the Arduino Password Door Lock Works
Before we start wiring, here is a quick overview of how this keypad door lock Arduino servo system works. As a result, understanding the flow will make the code and wiring much easier to follow.
The keypad is the input device. It is a 4×4 matrix with 16 buttons (digits 0–9, letters A–D, and symbols * and #). Specifically, when you press a key, the Keypad library scans the row and column lines to detect which button was pressed and returns the corresponding character to the Arduino.
The I2C LCD is the output display. It shows prompts such as “Enter Password” when the door is locked, displays asterisks as you type (to mask your input), shows “Door is OPEN” after a successful unlock, and displays “Wrong Password” if the code is incorrect. Moreover, because it uses the I2C protocol, it only needs two data wires (SDA and SCL) instead of six or more.
The servo motor acts as the physical lock mechanism. When you enter the correct password and confirm with #, the servo rotates from the locked angle (default 0°) to the unlocked angle (default 90°), simulating a door latch opening. Conversely, pressing * sends it back to the locked position. If you are new to servo motors, check out our servo motor Arduino tutorial for a deeper introduction.
Password Logic and System Flow
The password logic is handled entirely in the Arduino sketch. The code stores a preset password string (default “1234”). As the user types digits, the sketch appends them to an input buffer. When the user presses #, the sketch compares the buffer to the stored password. If they match, the door unlocks. Otherwise, an error message appears. In addition, the * key clears input or relocks the door, and D works as a backspace key.
Here is the full system flow:
- The LCD shows “Enter Password and #”.
- You type digits on the keypad. The LCD masks each digit as an asterisk (*).
- Press # to submit. The Arduino compares your input to the stored password.
- If correct, the servo rotates to the unlock angle and the LCD shows “Door is OPEN — Enter * to close”.
- The door stays open until you press *. Then the servo returns to the lock angle.
- If the password is wrong, the LCD shows “Wrong Password — Try again” for 1.5 seconds, then returns to the entry prompt.
Components Required (Bill of Materials)
Here is everything you need to build this DIY Arduino password lock. In fact, most of these parts come in standard Arduino starter kits.
| عنصر | الكمية | مطلوب / اختياري | غاية | ملحوظات |
|---|---|---|---|---|
| أردوينو أونو (أو لوحة متوافقة) | 1 | مطلوب | Main microcontroller | Nano or Mega also work with minor pin changes |
| 4×4 Matrix Keypad | 1 | مطلوب | Password input (8 pins) | Typically, membrane type is easiest to mount |
| 16×2 LCD Display with I2C Adapter | 1 | مطلوب | User feedback and prompts | Check I2C address: usually 0x27 or 0x3F |
| SG90 Servo Motor | 1 | مطلوب | Physical lock/unlock mechanism | Use external 5 V supply for reliable operation |
| أسلاك توصيل | ~20 | مطلوب | All connections | من الذكور إلى الذكور ومن الذكور إلى الإناث |
| لوح التجارب | 1 | مطلوب | Prototyping | Half-size or full-size |
| External 5 V Power Supply (1 A+) | 1 | Recommended | Reliable servo power | USB power alone may cause resets |
| Small Door Latch or Lock Mechanism | 1 | خياري | Physical demo enclosure | 3D-printed or off-the-shelf latch |
| Buzzer (active or passive) | 1 | خياري | Audio feedback on wrong password | Connect to any free digital pin |
Circuit Diagram and Wiring
Below is the circuit diagram for the Arduino keypad LCD servo project. The wiring is straightforward because the I2C LCD only needs two data lines, and furthermore, the keypad connects directly to eight digital pins.

LCD I2C Connections
| LCD I2C Pin | دبوس أردوينو | ملحوظات |
|---|---|---|
| السبتيين | A4 | خط بيانات I2C |
| SCL | A5 | خط ساعة I2C |
| VCC | 5 فولت | Power |
| أرضي | أرضي | Ground |
4×4 Keypad Connections
| Keypad Pin | وظيفة | دبوس أردوينو |
|---|---|---|
| Pin 1 | Row 1 | D9 |
| Pin 2 | Row 2 | D8 |
| Pin 3 | Row 3 | D7 |
| Pin 4 | Row 4 | D6 |
| Pin 5 | Column 1 | D5 |
| Pin 6 | Column 2 | D4 |
| Pin 7 | Column 3 | D3 |
| Pin 8 | Column 4 | D2 |
توصيلات محرك المؤازرة
| سلك المؤازرة | يتصل بـ | ملحوظات |
|---|---|---|
| إشارة (برتقالي/أصفر) | D10 | PWM-capable pin |
| VCC (أحمر) | 5 V (external recommended) | Important: servo draws up to 500–700 mA under load |
| GND (بني/أسود) | أرضي | Also must share common ground with Arduino |
Important power note: The SG90 servo can draw enough current to reset the Arduino if powered only through USB. Therefore, for reliable operation, use an external 5 V / 1 A (or higher) power supply for the servo. Also, connect the supply’s ground to the Arduino ground so they share a common reference. If you have worked with our Arduino IR remote servo project, the same power advice applies here.
Arduino Code for the Password Door Lock
Below is the complete Arduino sketch for this electronic door lock with Arduino. However, before uploading, make sure you have installed the following libraries through the Arduino IDE Library Manager: سلك, LiquidCrystal_I2C, Keypad, ، و محرك سيرفو.
Supported Features
This sketch supports the following features:
- Password entry — type digits on the keypad to build the input string.
- Masked input — the LCD shows asterisks instead of the actual digits for privacy.
- Unlock on correct code — press # to submit; if the input matches the stored password, the servo unlocks.
- Relock with * — when the door is open, press * to lock it again.
- Backspace with D — press D to delete the last entered character.
- Clear input with * — while the lock is active, press * to clear all entered digits and start over.
- Wrong password feedback — the LCD shows an error message for 1.5 seconds before returning to the entry prompt.
/**
Password Door Lock
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <Servo.h>
// LCD
#define LCD_ADDR 0x27
LiquidCrystal_I2C lcd(LCD_ADDR, 16, 2);
// Servo
#define SERVO_PIN 10
#define LOCK_ANGLE 0
#define UNLOCK_ANGLE 90
Servo lockServo;
// Keypad
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] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// Password
String PASSWORD = "1234";
String input = "";
bool doorUnlocked = false;
void lcdPromptLocked() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter Password");
lcd.setCursor(0,1);
lcd.print("and #");
}
void lcdPromptUnlocked() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Door is OPEN");
lcd.setCursor(0,1);
lcd.print("Enter * to close");
}
void lockDoor() {
lockServo.write(LOCK_ANGLE);
doorUnlocked = false;
lcdPromptLocked();
input = "";
}
void unlockDoor() {
lockServo.write(UNLOCK_ANGLE);
doorUnlocked = true;
lcdPromptUnlocked();
input = "";
}
void wrongPasswordMsg() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Wrong Password");
lcd.setCursor(0,1);
lcd.print("Try again");
delay(1500);
lcdPromptLocked();
input = "";
}
void handleKey(char k) {
if (doorUnlocked) {
if (k == '*') lockDoor();
return;
}
if (k == '#') {
if (input == PASSWORD) unlockDoor();
else wrongPasswordMsg();
} else if (k == '*') {
input = "";
lcdPromptLocked();
} else if (k == 'D') {
if (input.length() > 0) input.remove(input.length()-1);
} else {
if (input.length() < 8) input += k;
}
lcd.setCursor(0,1);
lcd.print(String(input.length(), '*'));
}
void setup() {
lcd.init();
lcd.backlight();
lockServo.attach(SERVO_PIN);
lockDoor();
}
void loop() {
char key = keypad.getKey();
if (key) handleKey(key);
}
Code Breakdown: Understanding the Arduino Password Door Lock Sketch
This section walks through the code step by step. If you are new to Arduino programming, reading this breakdown alongside the full code above will help you understand exactly how each part works.
1) Libraries and Objects
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <Servo.h>
// LCD
#define LCD_ADDR 0x27
LiquidCrystal_I2C lcd(LCD_ADDR, 16, 2);
// Servo
#define SERVO_PIN 10
#define LOCK_ANGLE 0
#define UNLOCK_ANGLE 90
Servo lockServo;
These four libraries handle I2C communication (سلك), the LCD display (LiquidCrystal_I2C), keypad scanning (Keypad), and servo control (محرك سيرفو). Consequently, the lcd و lockServo objects are created here and used throughout the sketch.
2) Hardware Configuration (Pins and Angles)
#define LCD_ADDR 0x27
#define SERVO_PIN 10
#define LOCK_ANGLE 0
#define UNLOCK_ANGLE 90
LCD_ADDR is the I2C address of your LCD backpack. Most modules use 0x27, but some use 0x3F. If your LCD stays blank after uploading, try changing this value. You can run an I2C scanner sketch to detect the correct address. SERVO_PIN defines which Arduino pin drives the servo signal. LOCK_ANGLE و UNLOCK_ANGLE set the two positions of the servo — adjust these to match the physical range of your latch.
3) Keypad Layout and Wiring
const byte ROWS = 4, COLS = 4;
char keys[ROWS][COLS] = { ... };
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
ال keys array maps the physical 4×4 button grid to characters. Importantly, the row pins (9, 8, 7, 6) and column pins (5, 4, 3, 2) must match your physical wiring. If keys return the wrong characters, the most likely cause is that the row or column pin order does not match the keypad’s pinout. As a result, the Keypad library handles debouncing and key detection automatically.
4) Password State and Variables
String PASSWORD = "1234";
String input = "";
bool doorUnlocked = false;
PASSWORD is the correct code the user must enter. Notably, you can change it to any combination of digits and letters up to 8 characters. input is a buffer that stores what the user has typed so far. doorUnlocked tracks whether the door is currently open or closed. Furthermore, a note for advanced users: using the Arduino String class on small microcontrollers (like the ATmega328 on the Uno) can cause memory fragmentation over very long run times. For a door lock that runs 24/7, consider using a fixed char array instead.
5) LCD Helper Screens
void lcdPromptLocked() { ... } // "Enter Password" / "and #"
void lcdPromptUnlocked() { ... } // "Door is OPEN" / "Enter * to close"
These two functions define the two main LCD screens. lcdPromptLocked() shows “Enter Password / and #” when the door is locked. lcdPromptUnlocked() shows “Door is OPEN / Enter * to close” when the door is unlocked. As a result, keeping these as separate functions makes the code cleaner and easier to modify.
6) Door Control Helpers
void lockDoor() { ... }
void unlockDoor() { ... }
lockDoor() moves the servo to LOCK_ANGLE, resets the state to locked, refreshes the LCD prompt, and clears the input buffer. unlockDoor() does the opposite — rotates the servo to UNLOCK_ANGLE, sets the state to unlocked, and shows the “Enter * to close” prompt.
7) Feedback on Wrong Password
void wrongPasswordMsg() { ... }
When the entered password does not match, the LCD displays “Wrong Password / Try again” for 1.5 seconds (delay(1500)), then returns to the locked prompt and clears the input. In other words, the delay gives the user enough time to read the message before it disappears.
8) Central Input Logic — handleKey()
void handleKey(char k) { ... }
Essentially, this is the brain of the Arduino password door lock. Here is exactly what happens for each key press:
- If the door is already open: only the * key is accepted, which calls
lockDoor(). All other keys are ignored for safety. - # (submit): compares the
inputbuffer toPASSWORD. If they match, the door unlocks. Otherwise, the wrong-password message appears. - * (clear): while locked, pressing * clears all entered digits and resets the LCD prompt, letting the user start fresh.
- D (backspace): removes the last character from the input buffer. This is useful if you make a typo. The reason D is chosen is that it is the last letter key on the 4×4 keypad and is intuitively placed in the bottom-right area.
- Any other key (digits, A, B, C): appended to the input buffer as long as the maximum length (8 characters) has not been reached.
At the end of handleKey(), the second line of the LCD is updated to show the masked input — one asterisk for each character entered. Consequently, the actual password digits are never visible on the display, adding a layer of privacy.
9) Setup — One-Time Initialization
void setup() {
lcd.init(); lcd.backlight();
lockServo.attach(SERVO_PIN);
lockDoor(); // start locked
// optional welcome screen...
lcdPromptLocked();
}
setup() runs once when the Arduino powers on. It initializes the LCD, turns on the backlight, attaches the servo to pin D10, and calls lockDoor() to start in locked mode. As a result, the first thing the user sees is the “Enter Password” prompt.
10) Loop — Read Keys and React
void loop() {
char key = keypad.getKey();
if (key) handleKey(key);
}
ال حلقة() function runs continuously. It polls the keypad using keypad.getKey(). If a key press is detected, it passes the character to handleKey(). Because all the logic lives inside handleKey(), the loop stays clean and simple. There is no blocking code in the loop (except inside the wrong-password delay), so the system remains responsive.
How to Test and Calibrate the Lock
Once you finish uploading the code and completing the wiring, follow these steps to verify that every part of the system works correctly before mounting it on a door or enclosure.
Verify Keypad Input
Open the Arduino Serial Monitor (add Serial.begin(9600); in setup() و Serial.println(key); in حلقة() temporarily). Then, press each key and confirm the correct character appears. If you notice swapped or missing keys, double-check the row and column pin wiring order.
Verify LCD Output
When powered on, the LCD should display “Enter Password” on the first line and “and #” on the second line. In that case, if the screen is blank, adjust the contrast potentiometer on the I2C backpack (small blue screw on the back). Similarly, if the backlight is on but no text appears, the I2C address may be wrong (try 0x3F instead of 0x27).
Test Servo Direction and Angles
Next, enter the correct password and press #. The servo should rotate from 0° to 90° (or whatever you set for LOCK_ANGLE و UNLOCK_ANGLE). If the servo rotates the wrong way, swap the values of LOCK_ANGLE و UNLOCK_ANGLE in the code. Fine-tune these values in small increments (for example, try 10° and 80°) until the latch mechanism engages and disengages smoothly.
Check Mechanical Alignment
If you are mounting the servo on a physical door latch, make sure you align the servo horn with the latch bolt at the locked position. Attach the servo horn after setting the servo to LOCK_ANGLE so the starting position is correct. Finally, test the unlock and relock cycle several times to ensure smooth operation without binding.
Test with External Servo Power
In particular, if the servo jitters, moves erratically, or causes the Arduino to reset, switch to an external 5 V power supply. Specifically, connect the supply’s positive wire to the servo’s VCC, the supply’s ground wire to the servo’s GND and to the Arduino’s GND (common ground is essential). In fact, this is the most common hardware issue beginners encounter.
استكشاف الأخطاء وإصلاحها في المشاكل الشائعة
If something is not working, first check this list of common problems and solutions for the Arduino password door lock project.
Quick Reference: Problems and Solutions
| مشكلة | السبب المحتمل | حل |
|---|---|---|
| LCD screen stays completely blank | Wrong I2C address or contrast too low | Run an I2C scanner sketch to find the correct address. Adjust the contrast potentiometer on the back of the LCD module. |
| LCD backlight is on but no text | I2C address mismatch | Change LCD_ADDR from 0x27 to 0x3F (or vice versa) and re-upload. |
| Keypad does not respond at all | Wiring error or wrong pin mapping | Verify that the 8 keypad wires are connected to the correct Arduino pins (D9–D2). Check the keypad pinout datasheet. |
| Keys return wrong characters | Row/column pins are swapped | Reverse or rearrange the rowPins و colPins arrays in the code to match your physical wiring. |
| Servo jitters or resets the Arduino | Insufficient power from USB | Use an external 5 V / 1 A power supply for the servo. Connect grounds together. |
| Servo rotates in the wrong direction | Lock and unlock angles are swapped | Swap the values of LOCK_ANGLE و UNLOCK_ANGLE. |
| Unlock angle does not open the latch | Angle value does not match mechanism | Adjust UNLOCK_ANGLE in 5–10° increments until the latch disengages. |
| Correct password always shows “Wrong” | Trailing characters in input or typo in PASSWORD | Print the input variable to Serial Monitor to verify what is actually being compared. |
| Servo works once then stops | Brownout from power draw | Add a 470 µF capacitor across the servo power lines, or use a stronger power supply. |
| Compilation error: library not found | Libraries not installed | Install LiquidCrystal_I2C, Keypad, and Servo through the Arduino IDE Library Manager. |
Customize and Upgrade Your Arduino Password Door Lock
The basic version of this Arduino keypad door lock is just the starting point. Below you will find practical upgrade ideas organized by category.
Software Upgrades
- Change the password: edit the
PASSWORDvariable in the code (for example,String PASSWORD = "6789";). Also, use a mix of digits and letters A, B, C for a stronger code. - EEPROM-stored password: save the password to Arduino EEPROM so it survives power cycles. You can add a “change password” mode triggered by pressing A, where the user enters the old password, then the new one.
- Lockout after failed attempts: add a counter that disables input for 30–60 seconds after 3 incorrect attempts. As a result, this prevents brute-force guessing.
- Multiple user codes: store an array of valid passwords so different people can have different access codes.
- Auto-relock timer: add a timeout that automatically relocks the door if the user does not press * within a set time (for example, 10 seconds).
Hardware Upgrades
- Buzzer feedback: add an active or passive buzzer to beep on each key press, play a tone on correct entry, and sound an alarm on repeated failures.
- Relay and electric strike lock: replace the servo with a relay module driving an electric strike or magnetic door lock for a real-world installation. If you have worked with relays before, our Arduino IR remote and servo tutorial covers relay basics.
- Battery backup: add a rechargeable lithium battery with a charging module so the lock stays functional during power outages.
- Adjust servo mechanics: tune
LOCK_ANGLEوUNLOCK_ANGLEto match your specific latch. Some latches need 0° to 180°, others only 0° to 45°. - External 5 V power supply: always recommended for a permanent installation. Use a 5 V / 2 A supply and connect all grounds together.
Security Improvements
- Bluetooth unlock: add an HC-05 Bluetooth module so the door can also be unlocked from a smartphone app. See our Arduino HC-05 Bluetooth module tutorial for wiring and pairing instructions.
- RFID access: add an RFID reader (such as the RC522) alongside the keypad for two-factor authentication — card plus password.
- Data logging: log access attempts (with timestamps from a DS3231 RTC module) to an SD card for an audit trail.
- Tamper detection: add a vibration sensor or magnetic reed switch to detect forced entry attempts and trigger an alarm.
- Encrypted communication: for advanced builds, encrypt the Bluetooth or Wi-Fi communication channel to prevent password sniffing.
الأسئلة الشائعة
What is an Arduino password door lock?
An Arduino password door lock is a DIY electronic access-control system that uses an Arduino microcontroller, a keypad for entering a code, an LCD display for user feedback, and a servo motor (or relay) to physically lock or unlock a door. Furthermore, it is one of the most popular beginner Arduino projects because it combines input handling, display output, and motor control in a single practical application.
Which Arduino board should I use for this project?
Generally, an Arduino Uno is the recommended board for this project because it has enough digital pins for the keypad (8 pins), the servo (1 pin), and the I2C LCD (2 analog pins used as I2C). An Arduino Nano or Mega will also work. However, if you use a Mega, the I2C pins are different (SDA = pin 20, SCL = pin 21).
How do I change the password in the code?
Find the line String PASSWORD = "1234"; in the sketch and replace "1234" with your desired code. For instance, you can use digits (0–9) and letters (A, B, C). The maximum input length is 8 characters. Afterward, re-upload the sketch to the Arduino.
My LCD is blank. What should I do?
First, check the I2C address. Most LCD I2C modules use 0x27, but some use 0x3F. Run an I2C scanner sketch to detect the correct address, then update LCD_ADDR in the code. Additionally, check the contrast by turning the small potentiometer screw on the back of the I2C module. Finally, verify the SDA (A4) and SCL (A5) connections.
Why does the servo jitter or reset my Arduino?
Servo motors can draw 500–700 mA under load, which is more than the USB port or the Arduino’s onboard regulator can safely supply. The voltage drop causes the Arduino to reset or the servo to jitter. The solution is to power the servo from an external 5 V power supply rated at 1 A or more. Always connect the ground of the external supply to the Arduino’s ground.
Can I use a 3×4 keypad instead of a 4×4 keypad?
Yes, but you will lose the A, B, C, and D letter keys. Since the code uses D as backspace and * as clear/relock, a 3×4 keypad will still work for basic password entry and submission with #. You will need to update the ROWS, COLS, keys array, and pin arrays in the code to match the 3×4 layout.
How do I make the password survive a power cycle?
Use the Arduino EEPROM library to store the password in non-volatile memory. Specifically, write the password to EEPROM when it is changed, and read it back in setup(). This way, the password persists even if the board loses power. However, be aware that EEPROM has a limited write lifespan (about 100,000 writes per cell), so only write when the password actually changes.
Can this project control a real door lock?
Yes. For a lightweight latch, the SG90 servo can directly push or rotate a simple bolt. For heavier locks, replace the servo with a relay module connected to an electric strike lock or a solenoid lock. In this setup, the relay is triggered by a digital pin instead of a servo signal, and additionally, the code change is minimal (replace lockServo.write() with digitalWrite()).
Is this door lock secure enough for real use?
As a standalone project, this is suitable for low-security applications such as a workshop, a shared office cabinet, or a maker project demonstration. The Arduino stores the password in plain text in its flash memory, and the system does not encrypt the keypad input. For higher security, add a lockout mechanism after multiple failed attempts, use EEPROM with a password-change flow, and consider adding a second authentication factor like RFID or Bluetooth.
What libraries do I need to install?
You need four libraries: سلك (included with Arduino IDE by default), LiquidCrystal_I2C (by Frank de Brabander), Keypad (by Mark Stanley and Alexander Brevig), and محرك سيرفو (included with Arduino IDE by default). Install them through the Arduino IDE menu: Sketch → Include Library → Manage Libraries, then search for each name.
Can I add Bluetooth control to this lock?
Absolutely. Add an HC-05 or HC-06 Bluetooth module connected to the Arduino’s serial pins (or use SoftwareSerial on other pins). You can then send an unlock command from a smartphone app. For a full guide on setting up Bluetooth with Arduino, see our HC-05/HC-06 Bluetooth module complete tutorial.
Why is D used as the backspace key?
On a standard 4×4 keypad, the letter keys A, B, C, and D are on the right column. Because digits and # and * already have defined roles (input, submit, clear/relock), D is the most convenient remaining key for backspace. Alternatively, you can reassign it to any unused key by changing the condition in handleKey().
الموارد والمشاريع القادمة
Finally, ready to take your Arduino skills further? Here are useful resources and project ideas that build on what you have learned in this Arduino password door lock درس تعليمي.
Project Resources
- Video walkthrough: watch the full build and demo in our YouTube video tutorial.
- LiquidCrystal_I2C library: مستودع GitHub for documentation and examples.
- Keypad library: Arduino Playground documentation for advanced features and custom configurations.
دروس تعليمية ذات صلة من OmArTronics
- التحكم في محرك سيرفو باستخدام عصا التحكم وشاشة OLED — learn more about servo control and display output.
- Arduino IR Remote LED and Servo Door (DIY Guide) — another access-control project using an infrared remote instead of a keypad.
- Arduino HC-05/HC-06 Bluetooth Module Complete Tutorial — the foundation for adding Bluetooth unlock to your door lock.
- Arduino Radar with Ultrasonic Sensor and Servo Motor — another servo-based project that teaches sweep mechanics and sensor integration.
Suggested Follow-Up Projects
- Bluetooth door lock: قم بدمج قفل لوحة المفاتيح هذا مع وحدة HC-05 حتى تتمكن من فتح القفل عبر الهاتف عندما تكون يداك مشغولتين.
- التحكم في الوصول باستخدام تقنية RFID: أضف قارئ RC522 RFID للدخول باستخدام البطاقات بجانب لوحة المفاتيح.
- لوحة التحكم بالمنزل الذكي: قم بدمج هذا القفل مع وحدة ترحيل، و ESP8266/ESP32 Wi-Fi، ولوحة تحكم سحابية للمراقبة والتحكم عن بعد.
- نظام أمني متعدد المناطق: يمكن توسيع النظام ليشمل أبوابًا متعددة باستخدام وحدة Arduino Mega مركزية وقائمة LCD لإدارة المناطق.
خاتمة
في هذا الدرس التعليمي، قمت ببناء نموذج كامل Arduino password door lock باستخدام لوحة مفاتيح مصفوفة 4×4، وشاشة LCD بتقنية I2C 16×2، ومحرك سيرفو SG90. قمت بتوصيل الدائرة، وتحميل البرنامج بالكامل، وتعلمت كيفية عمل كل جزء من أجزاء الكود - بدءًا من مسح لوحة المفاتيح والإدخال المقنّع وصولًا إلى مقارنة كلمات المرور والتحكم في محرك السيرفو.
لديك الآن برنامج يعمل قفل باب إلكتروني يمكنك تركيبه بنفسك يطلب هذا النظام كلمة مرور على شاشة LCD، ويقبل الإدخال من لوحة المفاتيح، ويفتح قفل المحرك المؤازر عند إدخال الرمز الصحيح، ويعيد قفله عند الضغط على *. بالإضافة إلى ذلك، أنت الآن تعرف كيفية استكشاف الأخطاء وإصلاحها في المشكلات الشائعة مثل شاشات LCD الفارغة، واهتزاز المحركات المؤازرة، وعناوين I2C الخاطئة.
علاوة على ذلك، يمكنك من هنا ترقية المشروع بإضافة خاصية تخزين كلمة المرور في ذاكرة EEPROM، وجهاز تنبيه صوتي، ونظام قفل تلقائي بعد محاولات فاشلة، وخاصية فتح القفل عبر البلوتوث للهواتف الذكية، أو حتى مرحل لتشغيل قفل كهربائي حقيقي. إذا أعجبك هذا المشروع، فاستكشف مشاريعنا الأخرى. دروس تعليمية حول أردوينو والروبوتات على موقع OmArTronics لمزيد من التجارب العملية.
رأي واحد حول “Arduino Password Door Lock with Keypad and LCD”