Introduction: Key Safe

During weekdays, I seldom bring my key out, but this causes difficulty when my mother left the house. By having no other choices, my mom has to leave the key inside the cabinet beside the door, which has no guarantee of whether the key is safe or not. By having this key lock, the one who is leaving the house can left the key inside this box to prevent others from stealing the key without any protection. Inasmuch as my mom will either be home before dinner or after dinner, I will need to know whether I need to find something to eat or not. This is the reason why the lock prints “Get Some Food”.

Step 1: Prepare the Materials

Arduino Leonardo (Arduino)

Matrix Keypad 4x4 (Amazon)

LCD 16x2 (Amazon)

Micro Arduino Servo Motor SG90 (Amazon)

Jumper Wires Male to Female (Amazon)

Jumper Wires Male to Male (Amazon)

Laser Cut 3D Printed Case x1 (15x20x12cm)

Tape / Clay

Wood Glue


Breadboard / Welding Gun

Step 2: Code


1. Download 4 system from the library.

2. Make sure to declare the servo pin as 4 (any number except 2 or 3: both of them will not work if LCD occupies SDA and SCL).

3. Different rows and columns belong to different pins, so make sure to declare the correct one.

4. Set up own passcode for the lock.

5. “resetLocker” means when the system turns back to origin: LCD prints “Get Some Food” and “Pin”, and the servo turns to 40 degrees, which locks the box (the degree depends on different servo or the position of the servo).

6. “unlockdoor” works if the user enters the correct password, making the servo to turn to 110 degree (open) and the LCD print “pass”. In the other hand, the LCD will print “Wrong! Try Again” if the passcode is incorrect.

7. By pressing “*”, users can clear the password they entered; by pressing “#”, the machine can check for the passcode.

Step 3: The Circuit

1. Plug in all the wires in the pins declared for the coding part.

2. Be aware of the positive and negative electrode or else the components might break (positive electrode: 5V, negative electrode: GND).

3. If the breadboard occupies a large space, use a welding gun solder to connect the wires together. In order to let the circuit operate, make sure the wires are not burned out, and the solder surrounds the wires (Tips for welding: Use the welding gun to heat the wires, put in the solder to let it melt until the liquid surrounds the wires, then remove the welding gun and the solder).

4. Using a breadboard: pin 6-13 should be the keypad, pin 4 is for servo, LCD’s SCL and SDA connect to the two pins on the left. The positive and negative electrode of both servo and LCD should be in the positive and negative part of the breadboard, then use two other wires to connect the holes of the breadboard to 5V and GND.

5. Using a welding gun: pin 6-13 should be the keypad, pin 4 is for servo, LCD’s SCL and SDA connect to the two pins on the left. The negative electrode of both the servo and LCD should be in the two holes of GND, but there is only one 5V hole, which means the positive electrode of both the servo and LCD should be together using soldering and them connect both of the wires to the 5V wire.

Step 4: The Exterior: Laser Cut Box

1. Draw a laser cut box for the key lock, including 2 15x20cm pieces for top and bottom, 2 20x12cm pieces for front and back, and 2 15x12cm pieces for the sides. (This website is available for customizing a box for laser cutting)

2. Remember to include a 2x1cm keyhole, a 7x2.5cm LCD hole, a 2.5x0.5cm keypad hole, and a 3.5 cm diameter circle for opening the box.

3. Find a laser printer to print out the pieces of the case.

4. Use wood glue to assemble the pieces of the case.


Step 5: Assemble the Components

1. Finish putting the pieces from laser cutting together and form a box.

2. There should be an addition component for forming the box, which is the connection between the lid and the body of the case. By gluing three pieces of cardboard between them, the box will be able to open and close in a more safe and convenient way (make sure to glue only the two shortest sides of the paper and keep the middle part movable or else the user cannot open or close the case).

3. The keypad should go through the hole on the left in front and plug them in the correct pins.

4. Place the LCD in the hole on top to let the screen facing the user.

5. Turn the piece to the other side and try to arrange the space behind.

6. Stick the Leonardo Arduino board in the middle of the piece in order to have the shortest distance to other wire connection, then make sure the wires are all plugged in.

7. Measure the distance of the servo so the lock can go through the hole on the side to allow the lock becoming stable. If the servo is in the wrong place, the lock will not work or the servo will keep falling down.

8. Use pieces of clay or tape to stick the charger on the inner side of the box and connect the charger to the Arduino board, letting the machine to operate.

9. Tape the wire if needed (for a neater inner appearance and easier to open and close the safe).

Step 6: How to Operate

1. Drop the keys inside the hole (leaving the house).

2. Press “*” for clearing the password, and press “#” for checking the passcode (LCD).

3. If the passcode is incorrect, the lock will not open; if the passcode is correct, the lock will open (servo).

4. Take out the key by entering the right password (entering the house).