engineerkid
Published © GPL3+

Arduino Controlled Safe (Locker)

In this project I made a locker that opens when a correct password is entered.

BeginnerFull instructions provided5 hours1,575
Arduino Controlled Safe (Locker)

Things used in this project

Hardware components

Arduino Uno
×1
4*4 Keypad
×1
16*2 Lcd
×1
Led
×1
Servo motor
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1
Header wires
×1

Story

Read more

Custom parts and enclosures

Final Project

Here is a small video that shows the complete project and its working.

Schematics

Circuit Diagram

Interfacing the Keypad, Servo & led.

LCD Connections

Interfacing the 16*2 LCD

Code

Final Code

C/C++
Please Install the Password & Keypad libraries before compiling the program.
/*
***  DON'T FORGET TO DOWNLOAD AND INSTALL THE PASSWORD AND KEYPAD LIBRARIES   ***
JUST EXTRACT THEM IN ARDUINO LIBRARIES FOLDER
*/
#include <Password.h> //http://www.arduino.cc/playground/uploads/Code/Password.zip
#include <Keypad.h> //http://www.arduino.cc/playground/uploads/Code/Keypad.zip
#include <LiquidCrystal.h>
#include <Servo.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Servo myservo;
Password password = Password( "123" );//CHANGE THE PASSWORD HERE
byte led = 13;
const byte ROWS = 4; // Four rows
const byte COLS = 4; //  columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = { A0, A1, A2, A3 };// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = { 9, 8, 7, 6 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
pinMode(led, OUTPUT);
myservo.attach(10);
digitalWrite(led, LOW); // Turn the LED off
myservo.write(70);
lcd.begin(16, 2);
Serial.begin(9600);
lcd.print("ENTER PASSWORD");
lcd.setCursor(0, 1);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}
void loop(){
keypad.getKey();
}
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
Serial.print("Pressed: ");
Serial.println(eKey);
switch (eKey){
case 'A': checkPassword(); break;
case 'C': password.reset(); break;
default: password.append(eKey);
}
}
}
void checkPassword()
{
if (password.evaluate())
{
Serial.println("Success");
lcd.print("SAFE OPENED");
myservo.write(110);
digitalWrite(led,HIGH);
lcd.setCursor(0, 1);
lcd.print("");
password.reset();
}
else
{
Serial.println("Wrong");
lcd.print("SAFE CLOSED");
myservo.write(70);
digitalWrite(led,LOW);
lcd.setCursor(0, 1);
lcd.print("");
password.reset();
}
}

Keypad Test Code

C/C++
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte led = 13;
const int pass='1';
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {A0, A1, A2, A3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
pinMode(led, OUTPUT);
digitalWrite(led, LOW);           // Turn the LED off.
lcd.begin(16, 2);
Serial.begin(9600);
lcd.print("ENTER PASSWORD");
lcd.setCursor(0, 1);
keypad.addEventListener(keypadEvent);
}
void loop(){
char key = keypad.getKey();
if (key)
{
Serial.println(key);
lcd.print(key);
}
}
void keypadEvent(KeypadEvent key)
{
switch (keypad.getState())
{
case PRESSED:
if (key ==pass )
{
digitalWrite(led,HIGH);        // Remember LED state
}
else{digitalWrite(led,LOW);}
break;
}
}

Credits

engineerkid

engineerkid

13 projects • 0 followers
How To Protect Yourself From Coronavirus click above link☝☝☝

Comments