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!
🛡️ 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!
Arduino Uno
The brain that checks the password and controls the lock.
4x4 Membrane Keypad
Type in the secret code, digit by digit.
0.96" OLED Display (I2C)
Shows prompts like "Enter Code" and "Access Granted."
SG90 Micro Servo
Acts as the vault door's lock bolt.
Small Buzzer
Beeps on key presses and alarms on wrong codes.
Breadboard
For connecting everything without soldering.
Small Wooden or Cardboard Box
The vault body, with a hinged door for the lock bolt.
4x AA Battery Pack
Powers the vault once unplugged from USB.
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.
Step-by-Step Build Instructions
Ask an adult to help cut the box and mount the lock bolt. Let's build Lockie!
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.
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.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.
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.
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.
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.
// 🔐🤖 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.

Comments
Post a Comment