ECEN 103 lab project report
Haider Kalandar
04/30/2023
ECEN-103-151.1231
Ultrasonic Security System
An ultrasonic security system is a type of security system that uses ultrasonic waves to detect
the presence of an intruder. Ultrasonic waves are high frequency sound waves that are above
the range of human hearing (typically above 20 kHz).
The basic working principle of an ultrasonic security system involves emitting ultrasonic waves
from a transmitter and detecting the reflected waves using a receiver. The system is typically set
up such that the transmitter and receiver are placed at opposite ends of the area being
monitored.
When an intruder enters the monitored area, their movement will cause a disruption in the
ultrasonic waves, which will be detected by the receiver. This disruption will trigger an alarm or
other security measures, such as turning on lights or sending an alert to a security company.
Ultrasonic security systems are often used in combination with other security measures such as
motion detectors, cameras, and access control systems to provide a comprehensive security
solution. They can be used in a variety of settings such as homes, offices, warehouses, and
museums.
One advantage of ultrasonic security systems is that they can detect movement even in low light
conditions, making them ideal for use in areas where lighting may be a problem. However,
ultrasonic waves can be disrupted by certain materials such as soft fabrics or thick walls, so care
must be taken when setting up the system to ensure that it is effective.
We will be creating a small security device using Arduino with the following steps:
We prepare the following electronic parts to create the project:
1- Jumper wires (generic) 10 pcs.
Figure 1
2-LED (red+yellow+green) 3pcs.
Figure 2
3-Breadboard - 1pcs.
Figure 3
4-Ultrasonic Sensor - HC-SR04- 1pcs.
Figure 4
5-Resistor 220 ohm- 4pcs.
Figure 5
6-Buzzer- 1pcs.
Figure 6
7- Arduino UNO- pcs1.
Figure 7
Project description
Step 1: Assemble Materials
Step 2: Setup
We draw a circuit connecting map through Fritzing software.
Figure 8
Connect a red wire from the 5V pin on the Arduino to the positive channel of the
breadboard. Connect a black wire from the GND pin on the Arduino to the negative
channel of the breadboard:
• Buzzer = pin 3
On Ultrasonic Sensor:
• Echo = pin 6
• Trig = pin 7
LEDs:
• Red LED = pin 9
• Yellow LED = pin 10
• Green LED = pin 11
The green wires connected to the LEDs should be connected in line to the positive side
of the LED, while the negative side of the LED should be connected to the negative
channel of the breadboard using a 220-ohm resistor.
Step 3: Assembly – Breadboard
Firstly, let's connect the 5V and GND pin on the Arduino to the breadboard. As I
mentioned before, be sure that the wire attached to the 5V pin is connected to the
positive channel of the breadboard, and the wire attached to the GND pin is connected
to the negative channel of the breadboard.
Step 4: Assembly - Ultrasonic Sensor
Time to connect the HC-SRO4 ultrasonic sensor! A great tip is to place the ultrasonic
sensor as far right to the breadboard as possible and make sure that it is facing out.
Referring back to the setup picture, you should connect the GND pin on the ultrasonic
sensor to the negative channel on the breadboard. Next connect the Trig pin on the
sensor to pin 5 on the Arduino and connect the Echo pin on the sensor to pin 6 on the
Arduino. Lastly, connect the VCC pin on the ultrasonic sensor to the positive channel on
the breadboard.
Step 5: Assembly – LEDs
The next step is to connect the LEDs to the breadboard and Arduino. Attaching the LEDs
is pretty easy, there's a lot of repetition. Let's first attach the Green LED. So, the way to
do this, is to connect the anode (the longer leg) to pin 11 on the Arduino with a green
wire, and to connect the cathode (the shorter leg) to the negative channel on the
breadboard, using a 220-ohm resistor. Then repeat that step for the Yellow to pin 10 and
then the Red LED to pin 9, your setup should look similar to the picture above.
Step 6: Assembly – Buzzer
The last part of the setup for this, is connecting the buzzer to the breadboard and the
Arduino. This is one of the easiest parts of the whole setup. All that is required to do is
to connect the longer leg of the buzzer to pin 3 of the Arduino using a brown wire and
then connect the shorter leg of the buzzer to the negative channel of the breadboard
using a 220-ohm resistor.
It is HIGHLY recommended to use a resistor in connecting the shorter leg of the buzzer to
the negative channel of the breadboard. This greatly reduces the volume of the buzzer
and prevent it from dying to quickly.
Code
#define trigPin 7
#define echoPin 6
#define LEDlampRed 9
#define LEDlampYellow 10
#define LEDlampGreen 11
#define soundbuzzer 3
int sound = 500;
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDlampRed, OUTPUT);
pinMode(LEDlampYellow, OUTPUT);
pinMode(LEDlampGreen, OUTPUT);
pinMode(soundbuzzer, OUTPUT);
}
void loop() {
long durationindigit, distanceincm;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
durationindigit = pulseIn(echoPin, HIGH);
distanceincm = (durationindigit/5) / 29.1;
digitalWrite(LEDlampGreen, HIGH);
digitalWrite(LEDlampYellow, HIGH);
digitalWrite(LEDlampRed, HIGH);
if (distanceincm < 50) {
digitalWrite(LEDlampGreen, HIGH);
}
else {
digitalWrite(LEDlampGreen, LOW);
}
if (distanceincm < 20) {
digitalWrite(LEDlampYellow, HIGH);
}
else {
digitalWrite(LEDlampYellow,LOW);
}
if (distanceincm < 5) {
digitalWrite(LEDlampRed, HIGH);
sound = 1000;
}
else {
digitalWrite(LEDlampRed,LOW);
}
if (distanceincm > 5 || distanceincm <= 0){
Serial.println("Outside the permissible range of distances");
noTone(soundbuzzer);
}
else {
Serial.print(distanceincm);
Serial.println(" cm");
tone(soundbuzzer, sound);
}
delay(300);
}
This project I searched for on the Internet and found it in Project HUB, and I looked at it
and read its details and started to correct some errors in the connections between the
electronic parts and the Arduino board. When I used the code that operates the audio
sensing, the code did not work and gave me many errors that must be corrected, and I
began to correct and see the experiences of others in this. The field until I reached the
correct code that worked correctly.
When I started examining the project, I had to use a small car (toy) that moved with the
remote control in order to see how it was detected by the device. When I got close to a
certain distance in the programming, the green light lit up. When I got closer, the yellow
light turned on. When I got closer, the red light turned on, which prompted the alarm to
sound. This means that the project is correct in its directions represented in alerting that
foreign bodies are approaching.
Some of the problems that I encountered are not good connections through wires, so I
checked them and found some of them were badly connected and had internal parts, so
I started to change them with good ones.
In the future, one potential improvement to the Ultrasonic Security System could be the
incorporation of machine learning algorithms to improve the accuracy of the system and
reduce false alarms. Another potential improvement could be the integration of the
system with other security measures such as cameras or access control systems.
Overall, working on this theoretical project helped me gain a deeper understanding of
Ultrasonic Security Systems and their applications in the field of security. I learned about
the basic working principle of the system, its key components, and potential
improvements that can be made to enhance its effectiveness.
References
Krepak. 11/16/2023, Project HUB, Ultrasonic Security System, 04/30/2023.
https://projecthub.arduino.cc/Krepak/a6ea3ad5-fd23-49c9-a96c-5e6fcf97f2cc#.
Krepak, 11/16/2023, Figure1, Figure2, Figure3, Figure4, Figure5, Figure6, Figure7 and
Figure8, Project HUB, Ultrasonic Security System, 04/30/2023.
https://projecthub.arduino.cc/Krepak/a6ea3ad5-fd23-49c9-a96c-5e6fcf97f2cc#.