Security alarm.
in this week we're gonna build a smart device for our desk or backpack.
i selected to make a smart security device for bag
inspo: Backpack Anti-Theft Alarm : 11 Steps (with Pictures) - Instructables
Arduino uno
tinkercad
ultrasonic sensor
push button
LED + 220-ohm Resistor
buzzer
arduino uno
jomper wires
breadboard
Ultrasonic Sensor (HC-SR04): Detects distance to objects near the bag.
Push Button: Used to switch the security system ON or OFF.
Buzzer: Produces an alarm sound when someone is too close to the bag.
LED: Provides a visual warning when the alarm is triggered.
The project is a Smart Bag Security System.
When someone approaches the bag:
The Ultrasonic Sensor measures the distance to detect if an object (a hand or someone’s movement) comes closer than 15 cm.
If the system is ON (controlled by the push button), it activates the security check.
circuit on tinkercad
first, i start wiring using tinker cad:
VCC → 5V (Arduino UNO)
GND → GND (Arduino UNO)
Trig → Pin
Echo → Pin 10
Positive terminal (+) → Pin 6
Negative terminal (–) → GND
Long leg (Anode +) → 220Ω Resistor → Pin 7
Short leg (Cathode –) → GND
Pin 1 → Pin 8
Pin 2 → GND
(Using INPUT_PULLUP in the code, so no external resistor is required)
code
for coding:
code logic for alarm behavior:
The code turns the bag security system ON or OFF using a push button. When the system is ON, the ultrasonic sensor measures the distance. If someone comes closer than 15 cm, the buzzer and LED turn ON as an alarm. Otherwise, they stay OFF. If the system is OFF, both the buzzer and LED remain OFF.
After confirming that the components worked as expected in the simulation, I connected the actual components on a breadboard with the Arduino UNO. The ultrasonic sensor, push button, buzzer, and LED were all wired according to the design.
معلش بس هي الاسلاك ملعبكة حبتين
On Arduino:
first i start the code with defining the pins on my Arduino for every component.
definition
After that, at the set up i wrote the mode of each pin (which is output and which is input)
Setup
At the loop (runs continuously):
Read the state of the push button to check whether the system should be ON or OFF.
Measure the distance from the ultrasonic sensor by sending and receiving signals.
Store this measured distance in a variable so it can be compared later.
Print the distance values on the Serial Monitor for debugging and observation.
loop
Inside the loop, I used if conditions to control the behavior of the outputs:
First, the program checks whether the system is ON.
If the system is ON, then it checks the distance value.
If the distance is less than 15 cm, the buzzer and LED are activated (alarm mode).
If the distance is greater than or equal to 15 cm, the buzzer and LED are kept OFF.
If the system is OFF (regardless of distance), the buzzer and LED remain OFF.
if condition
for the prototype:
I first cut the cardboard to sheets to be a cube shape and i make holes to place the components.
welcome زنان
demo video
rewatching this week الاف المرات عشن قمة في الاهمية
i struggled with the code with writing it (bugs everywhere) with ; and {}
and at first of the code i forget to definr the pins
Debuging
BUG
Title of Media
Title of Media