Ideation
This week's idea is to create a smart program controlled by the Arduino, which receives a specific reading and then does a specific thing.
My idea for this week is a small safe that works with Arduino and the password is entered via the keypad to keep your things safe.
I will use Tinkercad to simulate the circuit before you send it to the breadboard
I will use the Arduino IDE to upload the code to the Arduino
For the electrical circuit
Jumper Wires.
Arduino
keypad 4*4
on/of switch : To open and close.
Servo Motor to open and close
Small breadboard: To connect the circuit.
Adaptor 9V :The source of electricity.
Buzzer to make a sound
For the body
I will use a hot glue gun to glue the cardboard and make the body.
I will use scissors to cut the cardboard to make the body.
I will use cardboard to make the body.
How my device works, I will use the keypad to enter the password which will be read by the Arduino, and by the Arduino if the password is correct the safe will open by rotating the servo motor and a light sound will be made by the buzzer, and if it is wrong the safe will not open and a loud sound will be made, and I added a close and open button to control the entire circuit if it is closed nothing of what I mentioned will happen and a message will appear that the button is closed
I started connecting the negative of the Arduino to the vertical lines of the board ,Then I connected the keypad to the Arduino as shown in the picture.
Then I connected the negative and positive of the servo motor to the negative and positive of the Arduino on the board, and connected the third terminal to one of the Arduino pins to control the motor via the Arduino.
Fourth, I connected Buzzer, makes a soft sound when the safe is opened, and a louder sound when an incorrect password is entered.
I connected the positive of the Buzzer to one of the Arduino pins and connected the negative to the negative of the Arduino on the board
Then, I connected On/Off switch, to control the circut
I connected one of it's leg to one of the Arduino pins and connected another to the negative of the Arduino on the board
Simulating circuit
Coding
First I started by defining the libraries that I would need in the code, which are a library for the servo and a library for the keypad, I defined a variable and put the values of the keypad in it, then I wrote some defined strings to use some codes from the keypad library, then I defined a variable to store the password and defined another to verify that the password was entered by the user, I defined another variable called angle that I would use for the servo motor, and defined another variable for time (I got some help from Google of course) :) for this particular variable
As for the set-up, I defined the servo pin, and the button and the buzzer , and I made the servo at an angle of 0.
As for the code that will be repeated, I had two basic things. If the button is open, the following will be done: First, get the keypad reading. Second, store it in the variable. Then, check if the entered password matches the password. The following is done: The servo rotates until it reaches a 90 degree angle, which opens the safe with a light sound from the buzzer. Otherwise, a loud sound is made and the servo motor does not rotate and the safe remains locked.
If the password is correct and the safe is opened, a time of 8 seconds is calculated, after which the safe is locked. In the last case, if the button is locked from the beginning, nothing I mentioned will be done and a message will be printed saying that the button is locked. At the same time, if the button is open and the motor is already running, then you close the button, the motor will lock immediately.
After I wrote the code and verified it, I uploaded it to the Arduino and moved to make the card board.
Cardboard
I started cutting the main parts of the safe.
I chose the part where I will install the keypad.
Then I cut out the specified part and glued the keypad to it.
I glued the board to the base.
Then I completed gluing the body of the safe except for the side of the keypad.
I glued a piece of cardboard a little higher than the board and glued the Arduino to it.
Then I connected the Arduino negative to the board
Then I connected the rest of the electronics, the keypad.
and connected the buzzer
and the servo motor
then the botton
Now all parts are connected
A small circular hole is made on the side for the adapter to pass through to the Arduino to connect electricity.
I used part of a straw to make the part that will connect the door to the motor.
Then I closed all the sides by placing the last one, which is the part that the keypad is attached to.
The last step is to put the motor in its place and connect it to the door.
And here is my safe
Working with my teammate Sara to do the task of the week helped me a lot.
I actually had a lot of problems this week :)
The first one is that I didn't connect or program the keypad before, so I followed the explanation videos on the portal this week, but the problem is that the keypad I have now is 4*4 not like the one in the video 3*4 so I searched on Google to see how to deal with the one I have and program it and if there is a difference in the code or connection, and I found this site that helped me a lot, the difference was small in fact all you have to do is add the letters in the extra column and connect an extra wire as well
The second problem was
After I connected the motor and the keypad to the circuit and tried them, they were working well, as well as the buzzer, but when I wanted to add a button to control the circuit, of course I added if condition and I had defined the pin in the set-up, but when I uploaded the code to the Arduino, the button did not work and what was printed was that the button was closed, which should appear in its solution that the button is closed, so I tried to open it, but the result was the same, so after a long effort I remembered that I should define the pin as (INPUT_PULLUP) and not just (INPUT) and another thing, which is that the condition must be if ( digitalRead(11) == LOW) {} not if ( digitalRead(11) == HIGH){} and after correcting the code, I uploaded it to the Arduino and it worked.
What I learned this week from coding and making a small device that is very similar in its requirements in Final Project, will help me a lot.
I think the most wonderful thing this week was working as a team to accomplish something new and produce acceptable results.
I designed and programmed this circuit, you can check it out