Introduction: Safe

Picture of Safe

I made a safe with my 3d printer a servo , lcd and a keyboard..

Step 1: Cables

Picture of Cables

i first connected all the cables to my arduino nano to their corresponding places

Step 2: Arduino

Picture of Arduino

I then runned this code :

#include <Servo.h>

char password[] = "3374"; //aquí escribimos la contraseña de 4 dígitos char numero[4]; //Cadena donde se guardaran los caracteres de las teclas presionadas int cursor = 0; int c = 0; int green = 10; int red = 11; int pinServo = 12; int vel=0;

//Se crea un nuevo objeto del servo Servo myservo; #include #include #include

#include

const byte numRows = 4; //number of rows on the keypad const byte numCols = 4; //number of columns on the keypad

//keymap defines the key pressed according to the row and columns just as appears on the keypad char keymap[numRows][numCols] = { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} };

//Code that shows the the keypad connections to the arduino terminals byte rowPins[numRows] = {9, 8, 7, 6}; //Rows 0 to 3 byte colPins[numCols] = {5, 4, 3, 2}; //Columns 0 to 3

//initializes an instance of the Keypad class Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

#define I2C_ADDR 0x27 #define BACKLIGHT_PIN 3 #define En_pin 2 #define Rw_pin 1 #define Rs_pin 0 #define D4_pin 4 #define D5_pin 5 #define D6_pin 6 #define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin, BACKLIGHT_PIN, POSITIVE); LCD *myLCD = &lcd;

void setup() { pinMode(green,OUTPUT); pinMode(red,OUTPUT); lcd.begin(20, 4); // initialize the lcd lcd.home (); lcd.setCursor(0, 0); // go home lcd.print("PASSWORD: "); delay(1000); myservo.attach(pinServo); }

void loop() {

char keypressed = myKeypad.getKey();

if (keypressed != NO_KEY) {

numero[cursor] = keypressed;

cursor = cursor + 1;

lcd.print("*"); if (cursor == 4)

{ if (numero[0] == password[0] && numero[1] == password[1] && numero[2] == password[2] && numero[3] == password[3])

{

c++; lcd.setCursor(7, 2); lcd.print("OPEN"); vel = 0; myservo.write(vel); delay(550); vel = 85; myservo.write(vel); digitalWrite(green,HIGH); lcd.setCursor(c, 1); cursor = 0; delay(1000); lcd.clear(); lcd.setCursor(0, 0); // go home lcd.print("PASSWORD: "); digitalWrite(green,LOW); } else { cursor = 0; lcd.setCursor(7, 2); lcd.print("WRONG"); digitalWrite(red,HIGH); delay(1000); lcd.clear(); lcd.setCursor(0, 0); // go home lcd.print("PASSWORD: "); digitalWrite(red, LOW); } } } }

Step 3:

Whwn you finish putting everything together you get an incredible Safe Box.

Comments

About This Instructable

489views

7favorites

License:

More by AdrianaM39:Plant feelingsCardboard Letter LightsSafe
Add instructable to: