Since security is a necessity, it shouldn't be hard to have. Security isn't just your own safety, it's also the security of your precious belongings. That's why we should always keep our precious items in safe places. Our project this week is to make a locker with password verification. The locker can be opened in 2 ways: a 4-digit password or through Bluetouth.
A battery as a source of electricity
Tinkercad to imagine my electric circuit before appling it.
A servo motor for opening and closing the door
Cardboard for prototyping
Keypad to get input (password) from the user
An USB cable for uploading the code on the Arduino
Arduino UNO as the brain and controller
Arduino IDE for uploading the code to the Arduino
A buzzer to make a sond when an incorrect password is given.
Bluetooth Transceiver to transfer and revieve Blutooth signals from the user's phone.
MIT app inventor to make a simple app to open the door lock or close it through bluetooth
First, I got my components. Please note that I used a 3x4 keypad not a 4x4 as the video recommended and I didn't use any push buttons or resistors or LCD.
I had 2 inputs: the keypad and the Bluetooth trancsiever.
And 2 outputs: the buzzer and the servo motor
Second, I drew my circuit on Tinkerkad to make sure everything is okay.
Note: I didn't find a Bluetooth transceiver in Tinkercad, but I did use it in the project.
The Bluetooth transceiver has normally 6 pins, but we only connect the 4 middle ones.
The first pin from the left (RXD) ---> TXD (d1) in the arduino
The second pin from the left (TXD) ---> RXD (d0) in the arduino
The third pin from the left ---> GND (ground)
The fourth pin from the left ---> to a 5V source
You need to download and access 2 important files, the keypad library (Keypad.h) and the servo motor library (Servo.h)
#include <Keypad.h>
#include <Servo.h>
The "void loop" was a little bit complicated. First, by using the "counter" variable I numbered the characters entered of the keypad and separated them into 5 variables that we declared in the beginning:
"digit1", "digit2", "digit3", "digit4" and "enter"
**Note that both the Blurtooth transceiver and the Serial Monitor have the same input way.
I made a little app so I could use it when my phone is connected to Bluetooth. It's very easy all you have to do is:
1- Go to MIT App Inventor
2- Sign up, it's free.
3- Click on create apps, and create yours.
**For more details about MIT app inventor watch this tutorial:
(1) HC-05 Bluetooth Module with Arduino-MIT App Inventor - YouTube
The keypad has many characters that should be declared in the part before the "void setup". We need to specify its characters, number of rows and number of columns so that the Arduino can easily get information from it.
You should always remember to disconnect the 2 pins (trigger and echo) before uploading, because Arduino uses these pins to transfer the code while compiling. When the compiling and uploading is finished reconnect them to their normal pins.
The cardboard prototype is very simple, I used a shoe box and cut a 3-edged square (not a whole square) as the door then glued my components to it.
**Note that a 3-second sound from the buzzer means that the password is right and 1-second means the password is wrong
Now that I have added my servo motor it looks more as a locker!
The locker can be opened manually (with the password) or by Bluetooth.
Using many input and output sources (as the keypad and the LCD) was kind of hard trying to put all the code together and I had to face dozens of bugs.
I learned a lot about debugging and how to find where the problem is.
I'm sure that this skill will be useful in overcoming any bugs I face in the final project.