Discover how to enhance locker security with Arduino Uno. Get step-by-step instructions and valuable insights in this comprehensive guide.

Upgrade Your Locker Security with Arduino Uno

Locker security with Arduino Uno

You can protect your locker using this simple locker security system. This system generates a beep sound whenever someone attempts to open the locked safe. This system generates an alert sound when some light falls on it, in an open condition. If someone tries to open it then definitely some light will fall inside the locker, that light will be detected by the Light-dependent resistor and the buzzer will generate an alert beep sound.

If the locker is closed then there will be no light that will fall on the light-dependent resistor hence buzzer will be off.

Required Component

Circuit description

1.  Light-dependent resistor

LDR

Light-dependent resistor (LDR) works on the principle of photoconductivity. The light-dependent resistor is also known as a photoresist or photocell. It is a kind of variable resistor whose resistance value varies with the light intensity falling on it. Therefore, light-dependent resistors are light-sensitive devices that are used to identify the presence and the absence of light in multiple applications. In this system, a Light-dependent resistor is used to notify the buzzer to make the sound when light falls on it.

2. Piezo  Buzzer

Buzzer

The piezo buzzer is a simple audio signaling device that is preferred to generate a beep sound. Piezo buzzer consists of two legs one is longer (positive) and the other is a shorter leg (negative). The smaller leg is always connected to the ground and the longer leg is connected to the power supply.

According to this system whenever the light-dependent resistor detects light falling on it only then buzzer gets enough voltage to generate a beep sound. This sound will stop only when there is no light falling on the light-dependent resistor or when the locker is closed.

3. Liquid Crystal Display [LCD]

Liquid crystal display (LCD) is the most popular device used in electronic projects to display important information regarding the project. LCD is a 16-pin interface device.

Liquid Crystal Display [LCD] front view
Liquid Crystal Display [LCD] back view

Pin description of the LCD:

  • VSS or GND: Preferred for the ground connection.
  • VCC or VDD: Used to connect the +5 volt pin of the Arduino Uno board.
  • VEE or V0: Connected with the potentiometer to adjust the brightness of the LCD screen.
  • RS (Register Select): Used to select either instruction or data to be sent to the LCD screen.
  • RW (Read/Write): Used to select the mode either read or write.
  • E (Enable): Indicates to the LCD that data is ready to be written.
  • D0 to D7: Data pins.
  • A (Anode): +5 volt connected for the backlight of the LCD.
  • K (Cathode): The ground pin for the backlight of the LCD

4. Resistors

I have used the 100-ohm resistor along with the buzzer and 10 k ohm resistor along with the Light-dependent resistor for better results.

100 ohm resistor

10k ohm resistor


5. Jumper Wires

Male-to-male jumper wires are used to make the connection between all the components.

Male-to-male jumper

Circuit Schematic

According to this project, we will connect PINs 2, 3, 4, and 5 of the Arduino board to data pins 4 to 7 of the LCD. The reset pin of the LCD will be connected to PIN 12 and the enable pin will be connected to PIN 11 of the Arduino board. RW (read/ write), K (cathode), and the GND pin of the LCD will be connected to the GND pin.

The buzzer will be connected along with the 100-ohm resistor to PIN 6. The light-dependent resistor will be connected with analog pin A0 and a 10 k ohm resistor. Male-to-male jumper wires are used to make all the connections between devices.

You can understand the whole circuit connectivity with the help below-mentioned fritzing circuit schematic. In the fritzing diagram, I used a blue-colored wire connection to connect devices with Arduino Uno from the breadboard. The red-colored wire connections indicate the wired connectivity between LCD and Arduino Uno. The black-colored wires were used for the ground connections.

Circuit Schematic:

Source code

After connecting all the devices, the source code is uploaded via a USB cable. I am providing the full source code. you can understand the whole code with the help of comments provided for each statement. 

/*
*Locker guard based on Arduino Uno
* This system generates a beep sound whenever someone attempts to open the locked safe. 
*
*for more detail about this project please visit:
*https://arduinounomagic.com/locker-guard-based-on-arduino-uno-story/

*Copyright (C) 2007 Free Software Foundation, Inc. <[email protected]>
*for more projects based on Arduino uno please visit: https://arduinounomagic.com/
*/

#include<LiquidCrystal.h> // Include LCD header file.

 
LiquidCrystal G_LCD(12, 11, 5, 4, 3, 2); // Configure pins of LCD {LCD object name(RS, Enable, data pin-4, data pin-5, data pin-6, data pin-7).
 
const intG_LDR=A0; // Connect LDR to pin AO
const int G_BUZZER=6; // Connect buzzer to pin 6
 
void setup() 
{
Serial.begin(9600);
G_LCD.begin(16, 2); // Initallize the dimension of the display (width, height)
G_LCD.clear(); // Clears the display
pinMode(G_LDR, INPUT); // Set LDR as input
pinMode(G_BUZZER, OUTPUT); // Set buzzer as output
}
 
void loop()
 {
G_LCD.setCursor(0,0); // Set the location of the displayed text to be written on LCD at colomn:0, row:0
G_LCD.print(“Sensor value:”); // This statement prints on LCD screen

G_LCD.print(analogRead(G_LDR)); // Read data from LDR and print on LCD

int light_sensor=analogRead(G_LDR);// Store the value of LDR in light_sensor named integer variable.
delay(200);
G_LCD.setCursor(0,2);// Set the location of the displayed text to be written on LCD at colomn:0, row:2
 
if (light_sensor>=100) // If the value of LDR stored in light_sensor is greater than and equal to 100 
{
 G_LCD.setCursor(0,1); // Set the location of the displayed text to be written on LCD at colomn:0, row:1
  G_LCD.print(“it’s bright“); //Its bright 
tone(G_BUZZER, 1000);// Buzzer on with 1 KHz sound signal
delay(1000); // Delay for 1 sec
noTone(G_BUZZER);// Stop sound
G_LCD.clear(); // Clear the display
}
else
{
   G_LCD.setCursor(0,1); // Set the location of the displayed text to be written on LCD at colomn:0, row:1

  G_LCD.print(“it’s dark“); //Its dark
noTone(G_BUZZER); //Stop sound
}
}

Output

you can understand the workings of this project by watching the video mentioned below.

Hope you like the article.

If you have any queries feel free to ask.

One Comment

Leave a Reply

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