Smart Hotel Locker System With PictoBlox

by santunayek387 in Circuits > Arduino

35 Views, 1 Favorites, 0 Comments

Smart Hotel Locker System With PictoBlox

d8477c4b-7a4f-4a94-8590-d8eacdad1962.png

The Smart Hotel Locker Lock System using PictoBlox and Arduino is a secure and user-friendly electronic locking system designed to protect guests' personal belongings in hotels. The system uses an Arduino Uno, 4×4 keypad, I2C LCD display, and servo motor to create a password-based locker mechanism. The user can enter a 4-digit security code through the keypad to lock the locker, and the same code is required to unlock it. The LCD provides real-time instructions and status messages such as "Code to Lock," "Safe Locked," "Code to Unlock," and "Wrong Code."

The system is programmed using PictoBlox, making it easy to understand and implement through block-based programming. This project demonstrates the practical application of embedded systems, automation, programming, and smart security technology in the hospitality industry. It can be further enhanced with features such as RFID access, fingerprint authentication, OTP-based unlocking, IoT monitoring, and mobile notifications.

Supplies

  1. Arduino Uno
  2. Servo
  3. Matrix keypad 4x4
  4. 16x2 lcd i2c display
  5. Jumper wires
  6. USB cable for Arduino
  7. Power adapter or battery (9v)


Circuit Diagram

circuit_image.png

The circuit consists of four main components connected to an Arduino Uno:

  1. 16×2 I2C LCD Display
  2. 4×4 Matrix Keypad
  3. Servo Motor
  4. Arduino Uno

Below is a detailed explanation of each connection.

1. Arduino Uno

The Arduino Uno acts as the main controller. It:

  1. Reads the password entered from the keypad.
  2. Displays messages on the LCD.
  3. Controls the servo motor to lock or unlock the locker.

2. I2C LCD Connections

The LCD uses the I2C communication protocol, requiring only four wires.

LCD Pin Arduino Uno Pin Purpose

GND GND Common Ground

VCC 5V Power Supply

SDA A4 Serial Data Line

SCL A5 Serial Clock Line

Working

  1. The Arduino sends text to the LCD through the SDA and SCL lines.
  2. The LCD displays:
  3. Code to Lock
  4. Code to Unlock
  5. Safe Locked
  6. Safe Unlocked
  7. Wrong Code
  8. Enter 4 digits

3. Servo Motor Connections

The servo motor acts as the electronic locking mechanism.

Servo Wire Arduino Pin Purpose

Red 5V Power Supply

Brown/Black GND Ground

Orange/Yellow D3 PWM Signal

Working

  1. Initially, the servo is at , representing the unlocked position.
  2. After entering a valid password, the Arduino sends PWM signals on Digital Pin 3, rotating the servo to 180° to lock the locker.
  3. When the correct password is entered again, the servo rotates back to , unlocking the locker.

4. 4×4 Matrix Keypad Connections

The keypad has 8 pins:

  1. 4 Row pins
  2. 4 Column pins

These pins are connected to the Arduino as follows:

Keypad Pin Arduino Pin

Row 1 D11

Row 2 D10

Row 3 D9

Row 4 D8

Column 1 D7

Column 2 D6

Column 3 D5

Column 4 D4

Working

  1. The Arduino continuously scans the rows and columns to detect key presses.
  2. Only numeric keys (0–9) are accepted as password digits.
  3. The # key confirms the entered password.
  4. The **A, B, C, D, and *** keys are not used in this project.


Flowchart

width_944.jpg

Flowchart Overview

This flowchart represents an electronic locker security system that uses a keypad for password entry, a servo motor for locking/unlocking, and an LCD display for user feedback.

Flow Description

1. Initialization Phase

  1. Start: The system begins
  2. Initialize Components: LCD display, Servo motor, and Keypad are initialized and ready for operation
  3. Display Prompt: LCD shows "Code to Lock" to prompt the user

2. Password Setup (Locking Phase)

  1. Enter Password: User enters a 4-digit password via keypad
  2. Press #: User confirms entry by pressing the # key
  3. Check Lock Status: System checks "Is Locker Locked?"
  4. If No (locker is currently unlocked), proceed to password validation
  5. If Yes (already locked), skip to unlock phase

3. Password Validation

  1. Check Length: "Is Password 4 Digits?"
  2. If Yes: Password is accepted and stored in memory
  3. If No: System rejects and waits for valid input
  4. Store Password: The 4-digit code is saved as the unlock key

4. Locking Mechanism

  1. Rotate Servo 180°: Servo motor rotates to locked position
  2. Locker Locked: Physical locking mechanism engages
  3. Display Update: LCD shows "Code to Unlock"

5. Unlock Phase

  1. Wait for Password: System waits for user to enter password
  2. Press #: User confirms password entry
  3. Password Verification: "Entered Password == Stored Password?"

6. Decision Outcomes

If the password is CORRECT (Yes):

  1. Rotate Servo to 0°: Servo returns to unlocked position
  2. Unlock Locker: Physical lock disengages
  3. Display Success: LCD shows "Safe Unlocked"

If Password is INCORRECT (No):

  1. Display Error: LCD shows "Wrong Code"
  2. Stay Locked: Locker remains secured
  3. System returns to waiting for password entry


Code

Code Logic – Smart Hotel Locker Security System

Step 1: Initialize the System

  1. Include the required libraries:
  2. Wire.h for I2C communication
  3. LiquidCrystal_I2C.h for the LCD
  4. Keypad.h for keypad input
  5. Servo.h for servo motor control
  6. Initialize the LCD, keypad, and servo motor.
  7. Set the servo to 0° (Unlocked Position).
  8. Display "Code to Lock" on the LCD.

Step 2: Wait for User Input

  1. Continuously scan the keypad for a key press.
  2. If a numeric key (0–9) is pressed:
  3. Add the digit to the entered password.
  4. Display * on the LCD instead of the actual number.
  5. Allow a maximum of 4 digits.

Step 3: Confirm Password

  1. When the user presses the # key:
  2. Check whether the locker is currently locked or unlocked.

Step 4: Lock the Locker

If the locker is unlocked:

  1. Verify that exactly 4 digits have been entered.
  2. If valid:
  3. Save the entered password.
  4. Rotate the servo from 0° to 180° to lock the locker.
  5. Display "Safe Locked".
  6. Set the locker status to Locked.
  7. Otherwise:
  8. Display "Enter 4 digits".
  9. Ask the user to re-enter the password.

Step 5: Unlock the Locker

If the locker is already locked:

  1. Compare the entered password with the stored password.
  2. If both passwords match:
  3. Rotate the servo from 180° to 0°.
  4. Display "Safe Unlocked".
  5. Set the locker status to Unlocked.
  6. If the passwords do not match:
  7. Display "Wrong Code".
  8. Keep the locker locked.

Step 6: Reset Input

  1. After every lock or unlock attempt:
  2. Clear the entered password.
  3. Wait for the next user input.

Algorithm

  1. Start the program.
  2. Initialize the LCD, keypad, and servo motor.
  3. Display "Code to Lock".
  4. Read keypad input.
  5. If a number is pressed, store it and display *.
  6. If # is pressed:
  7. If locker is unlocked:Check if the password length is 4.
  8. If yes, store the password and lock the servo.
  9. Otherwise, display an error message.
  10. If locker is locked:Compare the entered password with the stored password.
  11. If matched, unlock the servo.
  12. Otherwise, display "Wrong Code".
  13. Clear the entered password.
  14. Repeat from Step 4 until the system is powered off.
Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <Servo.h>


LiquidCrystal_I2C lcd(0x27, 16, 2);


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] = {11, 10, 9, 8};
byte colPins[COLS] = {7, 6, 5, 4};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);


Servo lockServo;
const int servoPin = 3;


String enteredCode = "";
String storedCode = "";
bool isLocked = false;

void setup() {

lcd.begin(16,2);
lcd.backlight();

lockServo.attach(servoPin);
lockServo.write(0);
lcd.setCursor(0, 0);
lcd.print("Code to Lock:");
}

void loop() {
char key = keypad.getKey();
if (key) {
if (key == '#') {
if (!isLocked) {
if (enteredCode.length() == 4) {
storedCode = enteredCode;
lockSafe();
} else {
displayError("Enter 4 digits", 0);
}
} else {
if (enteredCode == storedCode) {
unlockSafe();
} else {
displayError("Wrong Code", 1);
}
}
enteredCode = "";
} else if (key >= '0' && key <= '9') {
if (enteredCode.length() < 4) {
enteredCode += key;
lcd.setCursor(enteredCode.length() - 1, 1);
lcd.print('*');
}
}
}
}

void lockSafe() {
isLocked = true;
lcd.setCursor(0, 0);
lcd.print("Locking Safe...");

for (int pos = 0; pos <= 180; pos += 1) {
lockServo.write(pos);
delay(15);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Safe Locked");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Code to Unlock");
}

void unlockSafe() {
isLocked = false;
lcd.setCursor(0, 0);
lcd.print("Unlocking Safe...");


for (int pos = 180; pos >= 0; pos -= 1) {
lockServo.write(pos);
delay(15);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Safe Unlocked");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Code to Lock");
}

void displayError(String message, int code) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(message);
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
if (code == 0)
lcd.print("Code to Lock");
else
lcd.print("Code to Unlock");
}

Conclusion

The Smart Hotel Locker Security System is a simple and effective Arduino-based project that provides secure access using a 4-digit password. The system integrates a 4×4 keypad for password entry, a 16×2 I2C LCD for user interaction, and a servo motor to simulate the locking and unlocking mechanism. When the correct password is entered, the servo unlocks the locker; if an incorrect password is entered, access is denied and an error message is displayed.

This project demonstrates the practical application of embedded systems, password authentication, servo motor control, and human-machine interaction. It serves as an excellent learning platform for understanding Arduino programming, digital input devices, display interfaces, and basic security system design. The project can be further enhanced by adding features such as EEPROM password storage, RFID or fingerprint authentication, GSM/Wi-Fi alerts, OTP verification, or mobile app control, making it suitable for real-world smart locker and hotel security applications.