This week i used my final project to make the assignment to save some time.
The idea is to switch on the secret button under the batman figure and put the bat key (which will be operated using IR sensor ) then the box will open .
if you pushed the button without the bat key the bat alarm will go .
original idea circuit
Tinkercad
I used it to simulate the circuit and try the code before any real simulation
Arduino
app I used the Arduino app to write the code .
Tinkercad
I used it to simulate the circuit wiring pins
Inputs : switch and IR sensor
Output : servo motor and buzzer
Brain : Arduino Uno
I started with each part
1-the switch :-
middle part : connect to pin 11.
and the +ve and -ve parts connected to the bread board
2-Servomotor:-
signal part : pin 10 on Arduino
+ve and -ve connected to the breadboard .
3-IR sensor
input connected to pin9 on Arduino
the +ve and -ve connected to the breadboard.
4- buzzer :
connected to pin 8 and the -ve part connected to the breadboard
Breadboard
to connect the components with the -ve and +ve : switch , servo , IR sensor and connected the -ve part of the buzzer
the input from
the switch = pin 11
and the
IR sensor = pin 9
the output :-
to the buzzer : pin 10
and
the servomotor : 8
you can find the code in the attachments
if {pin 11 and 9 read high
rotate servo 180}
if { pin 11 is high and the pin 9 is low
the alarm will go on }
1st I tried the code on the real circuit and I found out that on of the IR modules is broken so I replaced it .
Title of Media
The next step
I started to make the part that will contain the sensor and the switch
and started to imagine how it will be
putting the IR sensor and editing the distance
Then I made an opening for the bat key .
Testing the IR sensor after putting it inn the enclosure .
adding a batman logo the control part
the 2 nd part the box itself I started with getting a surgical masks box.
and I added a batman logo and a white cardboard to edit the shape .
Using a small cardboard box I have . I prepared it to put the servo motor on it .
I added the whole components .
and VOLA !!
Mohamed abdelfattah helped me with the code
the code was not working right
the alarm was on whether the IR sensor is on or off
The code was working wrong at the begging the alarm was on whether the IR is activated or not .
So my friend M .Abd el Fattah helped me and I changed the code the problem is that the if condition was ;-
if {the IR sensor and switch is on rotate the servo }
so
I had to write
{if the IR sensor and the switch is on... rotate the servo
and turn off the buzzer }
Title of Media
The idea is inspired by my final project
opening the box without the bat key will release the alarm
while turning on the switch with the bat key is in ( IR sensor activated )
Title of Media