0% found this document useful (0 votes)
10 views12 pages

Arduino-Based Safe Project Report

This document describes a project for a safe controlled by Arduino. The goal is to implement functions such as a keypad, LCD screen, servomotor, and LEDs to open the safe by entering a password. The password is stored in the EEPROM, and the servomotor rotates 90 degrees to open the door. The code manages user interaction through the keypad and the LCD screen.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views12 pages

Arduino-Based Safe Project Report

This document describes a project for a safe controlled by Arduino. The goal is to implement functions such as a keypad, LCD screen, servomotor, and LEDs to open the safe by entering a password. The password is stored in the EEPROM, and the servomotor rotates 90 degrees to open the door. The code manages user interaction through the keypad and the LCD screen.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AUTONOMOUS UNIVERSITY OF QUERÉTARO

FACULTY OF ENGINEERING
Arduino laboratory.
Report.
Safe
Jiménez Marco Polo.
Vallejo Martínez Rodrigo.
Professor: Georgina del Carmen Mota Valtierra.

Introduction.

Arduino allows us to develop programs that interact with the world such as sensor networks,
simple robotics, alarms, communication systems.
In this project, we will see the operation of a stereotype of moving a servomotor with some
characteristics that we will give to what we will call safe.
Where we will try to connect all these points based on the functions already seen in Arduino for the
operation of the safe where the interaction with the user will be to send a character that will be the
password that will open the safe.

Objective.

The objective of the safe project is to implement all the programs we have seen in
past practices, such as matrix keyboard, LCD screen, servomotor, LEDs, etc., to incorporate them into a single
project that this will be, in which all the functions seen will perform a single purpose 'to open a safe'
utilizando algunas funciones que nos ofrece arduino.

Necessary materials.
LCD screen
Arduino
Breadboard
Cables
Matrix keyboard
Servo motor
Caimans
Potentiometer
LEDs
Development.

To start with the project, it was necessary to establish how the password for the safe would be stored.
So, for this, the Eeprom.h library was used, which allows storing a certain amount of data in memory.
internal of the arduino. Where the vector of the password used was saved in addition to a key of
administrator giving the possibility to forget the password. In addition to being used as a device
a matrix keyboard as input and an LCD screen as output where the password being typed is displayed
how it works when the safe opens and closes, the actuator used was a servomotor which turned 90
degrees to open and it showed closed as the default option, the servo's propeller worked as
box insurance in cooperation with a piece of wood located in the box.

For the assembly of the circuit and the Arduino, it was placed behind the door of the box, and a hole was made in
one of the sides to provide power to the box via the USB cable, the servo was placed on it
door yes like the LCD screen and the matrix keyboard.

For the assembly of the components needed for the operation of the safe, we used the
data that we already had from the other practices, that is, how the screen was connected to the keyboard, the cables of
servo motor and the wires of the potentiometer.
Diagrams and connections.
Code.
#include <Keypad.h> // Controls the keyboard
#include <LiquidCrystal.h> //controls the LCD
#include <Servo.h> //Control of the servomotor
#include <EEPROM.h> //Input/Output Control EEPROM

//*****************************************
//*** Declaration of local variables *****
//*****************************************
Servo secure; //servomotor
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //display LCD
const byte rows = 4;
const byte columnas = 4;
byte pinsRows[rows]= {9,10,11,12};
byte pinsColumns[columnas] = {14,15,16,17}; //A0,A1,A2,A3

char keys[rows][columns] = {
{'1','2','3','A'}, Keyboard Declaration
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'},
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, columnPins, rows, columns);

char co[5] = {'1','2','3','4'}; // stores the password in eeprom


char cl[5]; //stores the new password
char cn[5]; //confirmation of the password
char ca[7]= {'3','7','1','9','2','A'}; // admin key set
char cal[7]; // Admin key read
int counter = 0; //Tracks the position of the array
int cursorr = 6; //Holds the position of the cursor
int comp; // comparison between 2 arrays
int a; //aux

void setup(){

pinMode(19, OUTPUT); // LEDs THAT INDICATE OPEN(13) OR CLOSED(19)


pinMode(13,OUTPUT);
digitalWrite(19, HIGH); //turns on the closed led

for(int i =0;i<=3;i++){ //READ PASSWORD FROM EEPROM


co[i]= [Link](i); //store it in co[]
} //end of the for

[Link](18); // Pin of the servomotor


[Link](16, 2); //LCD configuration 16X2 (columns, rows)
[Link](6,1); // The number writing will always be on the second line starting from the 6th box
[Link]("____"); // Spaces to write
[Link](90); //Close door
[Link](0,0);
'A' to enter
delay(1000);
[Link](0,0);
cir the pass ");
delay(1000);
[Link](0,0);
'C' to change
delay(1000);
[Link](0,0);
the pass ");
delay(1000);*/
[Link](0,0);
**PASSWORD**

}//end of the setup

void loop() {
cl[contador] = [Link](); // store in the position counter the key pressed
if (cl[counter] != NO_KEY){ If a key was pressed then

switch (cl[counter]){ //conditions according to the key pressed

//*****************************************//
Check if the password is correct
//******************************************//
case 'A':

comp = check(cl, co) + 1; // comp stores if the 4 numbers are equal


if (comp==4){ if all 4 digits are the same then

lcdtextoizq(" **Correct**");
[Link](15); open door
green light();
delay(600);
Press B to close
delay(600);
Close

} //end of the if of comp >=4


else{ //if pressing 'A' are not equal
ledrojoblink();
lcdtextocentrado("Error");
delay(600);
[Link](0,1);
[Link](comp);
delay(500);
lcdnumber();
} // end of the else for if comp>=4
break; //break to case 'a'

//*************************************//
Close the door if B is pressed
//*************************************//
case 'B':
lcdtextocentrado("Cerrado");
delay(500);
[Link](90); //closes the lock
redled();
for(int i = 0 ; i<4;i++){ // deletes the temporary saved code
cl[i]='0';
} // end of for
lcdnumber();
break; //end of case B

case 'C':
repeatpass();
if (comp>=4){ //if the password matches then
Correct password
delay(500);
nuevapass();
return(); //re-enter
} //function change password
else{
lcdtextoizq("Could not change");

comp = verification(cn, cl);


if (comp >= 4) {
Correct
delay(500);
New pass
delay(500);
password saved
delay(500);
for(int i =0;i<=4;i++){
[Link](i, cl[i]);
for(int i =0;i<=4;i++){
co[i]= [Link](i);

lcdnumber();
lcdtitulo(" **PASSWORD** ");
break;//end case c

case '#': //admin section


admin();
break;

default:
write(cl);

} //end of the switch


}

} //end of the if when a key was pressed

if (counter==4){ //Make the cursor start again from square 6


contador=0;
cursorr=6;
}
}//end of the loop

//*********************************
//*****Functions section********
//*********************************

void lcdnumero(){ //reseta los valores del cursor del lcd asi como del contador
[Link](0,1); second line
");
[Link](6,1);
[Link]("____");
cursorr=6;
counter=0;
} //end of lcdresetparanumero

void lcdtextocentrado(String A){ //write the message second line 1st box
[Link](0,1);
[Link](" ");
[Link](6,1);
[Link](A); //prints the entered value
} //end of lcdresetparatexto

void lcdtextleft(String A){ //writes the message second line 6to square
[Link](0,1);
");
[Link](0, 1);
[Link](A); //prints the entered value
} //end of lcdresetparatexto

void redLight() { //turns on red led


digitalWrite(19, HIGH);
digitalWrite(13,LOW);
}

void ledrojoblink(){ //turns on red LED blinking


digitalWrite(19, HIGH);
digitalWrite(13, LOW);
delay(200);
digitalWrite(19, LOW);
delay(200);
digitalWrite(19, HIGH);
}

void greenLed(){ //turns on green led


digitalWrite(19, LOW);
digitalWrite(13, HIGH);
}

void writeValue(char *v){ //writes the value of an array at the current position of the counter
[Link](cursorr, 1);
[Link](v[counter]);
v[contador+1]= (' ');
delay(250);
[Link](cursor, 1);
*
cursorr++;
counter++;

int check(char *v1, char *v2){


int equal = 0;
for(int i = 0; i<=5; i++){
if(v1[i]==v2[i])
equal = equal + 1;
}
return equal;
}

void lcdtitle(String a){

[Link](0,0);
[Link](" ");
[Link](0,0);
[Link](a); //prints the entered value
} //end of lcdresetparatexto
void repeatPassword() {
int i = 0;
lcdtitle("Enter password");
delay(800);
previous step
delay(1000);
Finish with *
lcdnumber();
while (i<=4){ //will do this 4 times

cl[contador] = [Link](); //gets value


if (cl[counter] != NO_KEY) { //if a key is detected then

switch (cl[counter]){

case '*': // checks if the entered password is the same as the previous one
comp=0;
comp = check(cl, co);
if (comp>=4){ //if it is equal
centredlcdtext("Correct");
ledgreen();
delay(300);
ledrojo();
i=5;} //end if comp<=4
else{
centeredLCDtext("Error");
ledrojoblink();
i=5;
}//end else
break; //end of case *

default:
write(cl);
i++;
}//end of the switch
} // end of if no key
}//end of if counter==4
//end of while
}//end of the function repeatpass

void newpass() {
lcdtitle("New password intro");
End with 'D'
delay(1500);
ONLY NUMBERS
delay(1500);
lcdnumber();
while(counter<=4){ //four times the cycle

cl[contador] = [Link]();
if (cl[counter] != NO_KEY) { //if I wrote something

switch (cl[counter]){

case 'D':
if (counter >= 4) { // if they have already written 4 numbers
Re-enter it
delay(1000);
counter=5;
} // end of if counter == $
else { // if he didn't write 4 numbers
Password error

delay(500);
[Link](0,1);
lcdtextleft(" ");
[Link](counter);
counter = 5;
}//End of else
break;

default:
write(cl);
} // end of the switch

//end of if
}//fn del if no key

}//end of while

} //find new password

void returns() {
lcdtitle("Write again");
Finish with '#'
delay(1500);
lcdnumber();
while(counter <= 4) { //four times the loop

cn[counter] = [Link]();
if (cn[counter] != NO_KEY) { //if I wrote something

switch (cn[counter]){

case '#':
if (counter >= 3) { // if they have already written 4 numbers
Password read
counter=5;
}//end of if counter==$
else { // if did not write 4 numbers
Password error

delay(500);
[Link](0,1);
lcdlefttext(" ");
[Link](counter);
}//End of the else
break;

default:
write(cn);
}//end of the switch

//end of if
} //fn delete if no key

//end of while
}
find return pass
void admin(void){

admin pass
'*' = Accept
delay(1500);
lcdnumber();
cursorr=4;
while(counter<=8){
cal[contador]=[Link]();

if (cal[counter] != NO_KEY) { //if I wrote something

switch (cal[contador]){

case '*':
comp = verification(cal, ca);
if (comp>=6){
Hello admin
contador =20;
adminpass();
}
//end of if counter==$
else { // if you did not write 4 numbers
Password error
counter = 20;
**PASSWORD**
lcdnumber();
}

break;

default:
write(cal);
}//end of the switch

//end of if
} //fn del if no key

}//end of while

} //find admin

void adminpass() {
New password
Finish with '#'
delay(1500);
lcdnumber();
while(counter<=4){ //four times the loop

cn[counter] = [Link]();
if (cn[counter] != NO_KEY) { //si escribi algo

switch (cn[counter]){

case '#':
if (counter >= 3) { // if he/she has already written 4 numbers
Password read
for(int i =0;i<=4;i++){
[Link](i,cn[i]);
for(int i =0;i<=4;i++){
co[i]= [Link](i);
delay(500);
Password updated
counter = 10;
delay(500);
**PASSWORD**
Confirm with 'A'
} // end of if counter==$
else { // if did not write 4 numbers
Password error

delay(500);
[Link](0,1);
lcdtextoizq(" ");
[Link](counter);
} //End of else
break;

default:
write(cn);
}//end of the switch

//fin del if
}//fn del if no key

}//end of while
}
find return pass

Applications.
The use of the tools that Arduino offers us is reflected in different fields of life.
daily, an example of this is in the safes that work with arduino, where we incorporate
the Arduino techniques for its operation, some applications that use functions of
Arduino is seen in a robot that emulates a spirograph, which is capable of painting and creating drawings of
geometric shapes on a whiteboard, another example is where a traditional microwave is
turns into a smart device in which we would use a tablet and a board of Arduino that
It would reduce the wait time in the kitchen; the safe can also be called a secure briefcase.
where we can incorporate a GPS module among other examples.

Conclusions.
Arduino is an open-source hardware platform that can be used to develop objects.
autonomous interactives or can be connected computer software, as we did in the project
from the safe. Through the entry pins and a range of sensors, the user introduces the
The password must be four characters long, and if it is correct, the box will open; otherwise, it will beep.
As an error. In previous practices, we saw the operation of some Arduino accessories such as the
matrix keyboard, the servomotor, the LCD screen, which we now combine into a single project that was
the safe.

You might also like