
Interaction and Design
The core concept of this project is a Door Alarm. The system is designed to be placed near a doorframe, where an Ultrasonic Sensor (HC-SR04) continuously monitors the distance to any objects in its path. If someone passes through the door, the sensor detects the change in distance and triggers an alarm.
Components in Detail
- Ultrasonic Ranging (HC-SR04): The sensor sends out sound waves and measures the "time of flight" for them to return. This is translated into a distance value by the Arduino.
- Audio Output: A Buzzer is connected to digital pin 9. When the alarm is triggered, the Arduino generates pulses at a specific frequency to create a loud, attention-grabbing sound.
- Visual Effects: A Green LED is used as a status indicator. It is normally
OFFbut turnsONwhen the alarm is active. - Arduino Mega 2560: While an Uno could also work, the Mega provides plenty of pins and memory for expanding the project in the future.
Assembly Guide
1. Hardware Connection
Connect the HC-SR04 sensor to pins 2 (Echo) and 3 (Trig). Connect the buzzer to pin 9 and the LED to pin 13. Ensure all ground pins are connected together.
2. Software Calibration
The distance measured by the sensor is compared against a threshold value. You'll need to measure the width of your doorframe and set this value accordingly in the code using an if statement.
3. Enclosure and Mounting
Mount the entire system into a small box and attach it to the side of a doorframe. Make sure the sensor has a clear, unobstructed path across the door.
Security and Implementation
Once the system is powered and calibrated, any movement through the door will be detected within milliseconds, providing an immediate and reliable alarm. You can also experiment with different pulse patterns for the buzzer and LED to make the alarm more effective!