Secret Password Lock Using Arduino, OLED Display and Push Buttons

by DESHBOT in Circuits > Arduino

8 Views, 0 Favorites, 0 Comments

Secret Password Lock Using Arduino, OLED Display and Push Buttons

WhatsApp Image 2026-09-25 at 10.18.13 AM.jpeg

The Secret Password Lock is an Arduino-based security project that allows the user to enter a password using two push buttons.

A 128×64 OLED display is used to show the password entry screen. The password consists of a sequence of button presses.

In this project:

  1. D10 = Button 1
  2. D12 = Button 2

The programmed password is:

1 → 2 → 1 → 1

The password is hidden on the OLED using asterisks. If the correct sequence is entered, the display shows ACCESS GRANTED. If an incorrect button is pressed, the display shows WRONG! TRY AGAIN.


Supplies

des 1.jpeg
uno.jpeg
oled.jpeg
WhatsApp Image 2026-09-25 at 10.18.19 AM.jpeg

Components Required

ComponentQuantity

Deshbot shield

Arduino Uno/Nano

128×64 OLED Display

Push Buttons

Pin Connections


OLED Display

OLED PinArduino

VCC - 5V

GND - GND

SDA - A4

SCL - A5

Push Buttons

ButtonArduino

Button 1 - D10

Button 2 - D12

The other terminal of each button is connected to GND.

The program uses:

INPUT_PULLUP

so the button reads HIGH when released and LOW when pressed.

Working Principle

WhatsApp Image 2026-09-25 at 10.18.08 AM.jpeg


The system works as follows:

  1. The OLED displays the SECRET LOCK screen.
  2. The user presses either Button 1 or Button 2.
  3. The Arduino checks the pressed button against the next password value.
  4. If it is correct, the password position advances.
  5. A * appears on the OLED for each correct input.
  6. If all four inputs are correct, access is granted.
  7. If an incorrect button is pressed, the password entry is reset.
  8. The user can try the password again.


Password Position

The variable:

int position = 0;

keeps track of which password character the user needs to enter.

For example:

Password: 1 2 1 1
^
position 0

After pressing Button 1:

Password: 1 2 1 1
^
position 1

The process continues until the complete password is entered.


OLED Display

The initial display shows:

SECRET LOCK

_ _ _ _

D10 D12

After a correct button press, the corresponding position is hidden using *.

Example:

SECRET LOCK

* _ _ _

D10 D12

The actual password is not displayed.


Access Granted

When the complete password is entered correctly, the OLED displays:

ACCESS

GRANTED!

The message remains on the screen for approximately 3 seconds.

After that, the system returns to the password entry screen.


Wrong Password

If the user presses the wrong button, the OLED displays:

WRONG!

TRY AGAIN

After approximately 1.5 seconds, the password position is reset to zero and the user can try again.


Button Debouncing

The program uses a small delay to reduce accidental multiple readings from a button press.

delay(50);

It also waits until the button is released:

while (digitalRead(BUTTON_1) == LOW);

This helps make each physical button press count as one password input.


Main Features

  1. OLED password interface
  2. Two-button password input
  3. Four-digit button sequence
  4. Hidden password entry
  5. Correct password detection
  6. Wrong password detection
  7. Access-granted message
  8. Automatic password reset
  9. Button debouncing
  10. No external RTC or sensor required


Downloads

Conclusion


The Secret Password Lock project demonstrates how an Arduino can create a simple password-based access-control system using two push buttons and an OLED display.

The project combines button input, password arrays, conditional statements, OLED graphics and input validation to create an interactive security system. It provides a good foundation for developing more advanced electronic locking and access-control projects.