Skip to content
Intermediate 4 hours

Arduino Servo-Controlled Smart Door Lock

By Amit1379
July 13, 2026

This project builds a functional electronic combination lock. A 4×4 keypad takes PIN input, the Arduino compares it to the stored code, and a servo motor rotates a bolt or latch mechanism open on a match. Wrong PIN attempts trigger an LED alarm and a 30-second lockout — preventing brute-force entry. The PIN can be changed via a special sequence.

What You’ll Need

  • Arduino Uno or Nano
  • 4×4 membrane keypad
  • SG90 or MG90S servo motor
  • Red and green LEDs + 220 Ω resistors
  • Piezo buzzer
  • 16×2 I2C LCD (optional but helpful)
  • 9 V power supply
  • Project enclosure

Step-by-Step Instructions

  1. Install Keypad library: Install “Keypad” by Mark Stanley via Library Manager.
  2. Wire the keypad: The 4×4 keypad has 8 pins (4 rows, 4 columns). Connect to Arduino pins 2–9 according to your keypad pinout. Define the key map in code as a 4×4 character array.
  3. Wire servo: Servo signal wire to pin 10, VCC to 5 V, GND to GND. (Use an external 5 V supply for the servo if the lock mechanism is heavy — servos can draw more current than Arduino’s regulator provides.)
  4. Wire feedback: Green LED to pin 11, red LED to pin 12, buzzer to pin 13.
  5. State machine logic:
    • IDLE: LCD shows “Enter PIN: “. Keypress appends to input buffer.
    • CHECKING: On # key, compare buffer to stored PIN.
    • UNLOCKED: Servo rotates to 90° (open). Green LED on. LCD shows “Unlocked”. After 5 seconds, servo returns to 0° (locked).
    • DENIED: Red LED + buzzer 3 beeps. Increment fail counter. After 3 fails, LOCKOUT state for 30 seconds.
  6. Change PIN: Press * then current PIN + * + new PIN + # to update. Store new PIN in EEPROM so it survives power loss.
  7. Mount: 3D print or cut a bracket to attach the servo to a door latch mechanism. The servo horn pushes or rotates the latch bolt.

Safety Notes

  • This is a demonstration lock — do not use as the sole security measure for anything important.
  • Ensure a manual override always exists (physical key) in case of power failure.

Tips & Troubleshooting

  • If the servo jitters, the Arduino’s 5 V pin may not supply enough current — power the servo from a separate 5 V supply with shared GND.
  • Use EEPROM.put() / EEPROM.get() to save/retrieve the PIN as a char array.
  • Extend with an RFID module (MFRC522) for card-swipe access in addition to PIN.

Leave a Comment

Your email address will not be published. Required fields are marked *