# Lock Box

(Redirected from Blink box)

## Overview

Everybody has something valuable which they do not want to be stolen. This is why some people decide to put their things in a lockable box. The Lock Box project involves making just that: a box that the user can lock and unlock and hold his/her things. The box can be unlocked by turning a dial like a combination padlock, but instead of the code being physically ingrained in the device, it is digitally stored and changeable. An Arduino Uno, ten Hall Effect sensors, some magnets, and a button are used to accomplish this. The Arduino is coded to have two different codes: one that is shorter (4 digits) and resettable, and one that is longer (8 digits) and permanent. The user can either unlock the box or reset the code by inputting the shorter code. The longer, permanent code is used as a backup code in case the user forgets what he/she set the shorter code to. The way the user interfaces with the Arduino is by pressing a button for a certain amount of time: single press to unlock and hold it down to reset the code. The state of the box is indicated by two LEDs so that the user can use the box more easily.

Yuanxiao Gao
Samuel Hoff
TA: Mo Wu

## Objectives

Make a box that is is able to be unlocked by putting in the correct combination. The combination will be entered by turning a dial, just like combination padlock. When the dial turns to a specific number, there will be a signal sent to an Arduino. When the user wants to enter a code he will press a button to select the action he wants to perform (change the code or unlock the box) and then enter the code with the dial. The way the number will be translated from the position of the dial to a number of the code is by using a Hall Effect sensor to detect a unique signal from the magnets. There will be two codes: one that is 4 digits long and one that is twice is long. The first code is changeable and when entered can both open the box and allow the user to change it. The second is a backup code that allows the user to change the first code, in case the user forgets the code.

The main goals of this project are to:
1. Design a dial and housing that allows the dial's position to an Arduino.

2. Build the interface that allows the user to specify which code he will be entering.

3. Write C++ code on Arduino IDE that allows the user to control the box.

4. Design the locking mechanism and the bottom part of the box.

5. Assemble and test.

## Challenges

Accurately reading a number based on the position of the dial.

Writing code to perform all of the functionality desired.

Finding a proper power supply.

Connecting all the parts into the circuit.

Coding in the language that will be read by Arduino.

## Budget

LEDs (Provided)

3-D printing (Provided)

Arduino UNO (Provided)

Push Pull Solenoid Motor ($19.11) https://www.adafruit.com/product/412 Hall Effect Sensors X 13 ($39.08) https://vetco.net/products/hall-effect-sensor-module-for-arduino?gclid=EAIaIQobChMIxJnC_dmC2AIV1UsNCh2s3w95EAQYASABEgIEe_D_BwE

Total: \$71.10

## Design and Solution

1. First, we have to test the hall effect sensors by connecting it to the Arduino. The “-” pin goes to the ground. The “S” pin goes to signal. The middle pin goes the power supply. We also need to place a 10K resistor between the “S” pin and the middle pin. .

2. After setting up the circuit and writing the simple code on the How to use hall effect sensor page on the Arduino, you can see the LED turns on when magnets are near the sensor. .

3. After this we started soldering all then hall effect sensors and resistors together in the shape of a circle and connected each sensor to the signal pin on the Arduino..

4. After finishing setting up the sensors, we added two LED lights to the circuit because we need them to show each state of the lock and also connected the button into the circuit which is used to change the state of the lock by pressing it once or pressing and holding it..

5. Then we need to connect the motor and the relay into the circuit. There are 4 pins on the relay we use. Pin1 goes to power Arduino. Pin2 goes to ground Arduino. Pin3 goes the positive of the batteries. Pin4 goes the negative..

6. We 3D printed the dial and the lid of the box. We glued all the parts on the lid and put the magnets in the dial and set the dial in the mid of the lid. The picture below shown how it is set up.

7. By coding, we accomplished the whole project. Code is attached below.

## Results

Our project is used just like a combination lock but the difference is what is inside. We put magnets in the dial and set 10 hall effect sensors around it. With 10 different inputs, Arduino can read number 0 to number 9. There is a resettable 4 digit code that the user can unlock the box with. There is an 8 digit backup code that can be entered to change the 4 digit code. The user selects an action with a button: a single press to unlock, hold to reset the code. Two LEDs are used to indicate the state. And it is exactly what we wanted it to be so our project is successful. We could have made it better if we 3D printed the box which would make the box more secure. For now, we just used cardboard. And also, when we were doing it found out that insufficient batteries is also a problem. We had to keep changing the batteries when the old batteries had been ran out. To make it better, we can maybe set another button to turn on/off the box which can make us use it longer. This could have been due to the wiring of the hall effect sensors, but it is not clear yet. Another improvement would be to remove the wires and replace them with a printed conductive material.
Link to the revised tutorial: https://classes.engineering.wustl.edu/ese205/core/index.php?title=Use_Hall_Effect_Sensors