Keypad Vault Bot: Battery-Powered Arduino Servo Lock | MakeMindz

DIY Keypad Password Vault 🔐 Arduino Servo & OLED Robotics Project for Kids
🔐 ROBOTICS FOR KIDS · LEVEL: INTERMEDIATE

Build a Secret Keypad Vault That Only Opens for You!

Meet Lockie — an Arduino-powered vault guard with a keypad, a tiny screen, and a servo-powered lock bolt. Type the secret code and watch the door swing open. Get it wrong, and Lockie sounds the alarm!

⏱️ 3–4 hours 🎂 Ages 9+ (with an adult) 📟 Keypad + OLED + Servo
****

🛡️ Say hi to Lockie, your robot vault guard!

What Is a Keypad Vault Robot, Anyway?

A keypad vault is a security robot that only unlocks when it hears the exact secret code. In this project, an Arduino reads button presses from a 4x4 keypad, shows helpful messages on a tiny OLED screen, and controls a servo motor that acts as the door's lock bolt.

This project is a great introduction to digital security logic — comparing what someone typed to a stored secret, and only then deciding to take action.

🧰

What You'll Need

Gather these parts before you start building your vault!

x1

Arduino Uno

The brain that checks the password and controls the lock.

x1

4x4 Membrane Keypad

Type in the secret code, digit by digit.

x1

0.96" OLED Display (I2C)

Shows prompts like "Enter Code" and "Access Granted."

x1

SG90 Micro Servo

Acts as the vault door's lock bolt.

x1

Small Buzzer

Beeps on key presses and alarms on wrong codes.

x1

Breadboard

For connecting everything without soldering.

x1

Small Wooden or Cardboard Box

The vault body, with a hinged door for the lock bolt.

x1

4x AA Battery Pack

Powers the vault once unplugged from USB.

~15

Jumper Wires

Male-to-male and male-to-female.

🔌

The Circuit Diagram

Here's how the keypad, OLED screen, servo, and buzzer all connect to the Arduino.

Arduino Uno UNO Pin 5 — Row 1 Pin 4 — Row 2 Pin 3 — Row 3 Pin 2 — Row 4 A0–A3 — Columns 1–4 A4 — OLED SDA A5 — OLED SCL Pin 9 — Servo Signal Pin 10 — Buzzer 5V GND 4x4 Keypad 8 pins (4 rows + 4 cols) OLED Display I2C — SDA / SCL Servo — Lock Bolt Buzzer — Beep/Alarm
Keypad rows → pins 5,4,3,2 Keypad columns → A0, A1, A2, A3 OLED (I2C) → A4 (SDA), A5 (SCL) Servo → pin 9 · Buzzer → pin 10
🛠️

Step-by-Step Build Instructions

Ask an adult to help cut the box and mount the lock bolt. Let's build Lockie!

1

Prepare the vault box

Cut a small hinged door into your box. Cut a window on the front panel for the OLED screen and a slot for the keypad.

2

Mount the keypad and OLED

Fit the keypad into its slot and the OLED into its window on the front panel, then connect both to the breadboard following the circuit diagram.

💡 Tip: Test the OLED alone first with a simple "Hello Vault!" message before wiring anything else.
3

Install the servo lock bolt

Mount the servo just behind the door frame with a small cardboard or plastic arm on its horn. When the servo rotates, the arm should slide out of a notch on the door to lock it, or pull back to release it.

4

Add the buzzer

Mount the buzzer inside the box near the front. It will beep softly on every key press, and sound a longer alarm tone if the wrong code is entered.

5

Wire everything to the Arduino

Carefully connect the keypad's 8 wires, the OLED's 4 wires, the servo's 3 wires, and the buzzer's 2 wires exactly as shown in the circuit diagram.

6

Upload the code and set your secret

Open the code below, change the secret password to your own, upload it, then switch to battery power. Type your code on the keypad and watch the vault unlock!

💻

The Arduino Code

This code needs the Keypad, Adafruit_SSD1306, and Servo libraries, installable from the Arduino Library Manager. Copy it in and click Upload.

keypad_vault.ino
// 🔐🤖 Lockie the Robot Vault — Arduino Keypad + Servo + OLED Project

#include <Keypad.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Servo.h>

// ---- OLED setup ----
Adafruit_SSD1306 display(128, 64, &Wire, -1);

// ---- Keypad setup ----
const byte ROWS = 4, COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {A0, A1, A2, A3};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

// ---- Servo + buzzer ----
Servo lockServo;
const int servoPin  = 9;
const int buzzerPin = 10;

// ---- Password setup ----
String secretCode = "1234";   // change this to YOUR secret code!
String enteredCode = "";

void setup() {
  lockServo.attach(servoPin);
  lockServo.write(0);   // 0 = locked position
  pinMode(buzzerPin, OUTPUT);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  showMessage("Vault Locked", "Enter Code:");
}

void loop() {
  char key = keypad.getKey();

  if (key) {
    tone(buzzerPin, 1200, 80);  // short beep on key press

    if (key == '#') {          // # submits the code
      checkCode();
      enteredCode = "";
    } else if (key == '*') {   // * clears the code
      enteredCode = "";
      showMessage("Cleared", "Enter Code:");
    } else {
      enteredCode += key;
      showMessage("Enter Code:", enteredCode);
    }
  }
}

// Compares the typed code to the secret code
void checkCode() {
  if (enteredCode == secretCode) {
    showMessage("Access Granted", "Welcome!");
    lockServo.write(90);   // 90 = unlocked position
    tone(buzzerPin, 1800, 300);
    delay(4000);
    lockServo.write(0);    // re-lock automatically
    showMessage("Vault Locked", "Enter Code:");
  } else {
    showMessage("Access Denied", "Try Again!");
    for (int i = 0; i < 3; i++) {
      tone(buzzerPin, 400, 200);
      delay(300);
    }
    delay(1000);
    showMessage("Vault Locked", "Enter Code:");
  }
}

// Shows a title and a message line on the OLED screen
void showMessage(String title, String message) {
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 10);
  display.println(title);
  display.setCursor(0, 35);
  display.println(message);
  display.display();
}
🧠

How Does Lockie Actually Work?

Here are the big robotics ideas hiding inside this project:

🔢

Matrix Scanning

The keypad doesn't have 16 separate wires — it cleverly uses just 8 (4 rows + 4 columns) and scans through them super fast to figure out which button you pressed.

🔤

Comparing Text

The code builds up everything you type into a String, then compares it to the secret code using == — the exact same idea real password checkers use.

🖥️

The OLED Screen

The OLED talks to the Arduino using just 2 wires (I2C: SDA and SCL), letting it display text without using up lots of extra pins.

🔁

Auto Re-Locking

After granting access, the code waits a few seconds, then automatically moves the servo back to the locked position — so you never forget to lock up again!

🧑‍🔬 Safety First!

  • Build with an adult, especially when cutting the box and wiring the OLED and servo.
  • Never store real money, jewelry, or valuables — this is a fun learning project, not a real safe.
  • Keep small parts away from little siblings and pets.
  • Handle the OLED screen gently — the glass can crack if dropped.
  • Change the default secret code before showing off your vault to friends!

Frequently Asked Questions

How do I change the secret password?

Just edit the secretCode line near the top of the code — for example, change "1234" to any 4-digit (or longer) code you like, then re-upload.

What do the A, B, C, D buttons do?

They're extra keys on a 4x4 keypad that aren't used in this basic project — but you could program them to do things like reset the password or turn on a night-light!

Can I add more security, like a wrong-attempts lockout?

Yes! You could add a counter variable that tracks failed attempts, and if it reaches 3, make Lockie display "Locked Out!" and ignore the keypad for 30 seconds.

What age group is this project good for?

This project works well for kids around age 9 and up, especially with an adult helping wire the keypad and OLED display correctly.

🎉 Fantastic work — you just built a real password-protected robot vault! Type in your secret code and watch Lockie let you in.

⬆️ Back to Materials List

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course