Arduino Alarm With Ultrasonic Sensor
Intro: Arduino Alarm With Ultrasonic Sensor
This instructable is about how to make an easy and cheap alarm device by youself.All you need is basic knowledge in electronics and arduino programming.
If you have any questions or problems you can contact me on my mail:iwx.production@gmail.com
Here is also video of this project:
So let's begin.
STEP 1: Watch the Video
You can also see on video how this project is working.
STEP 2: Materials
-Arduino Mega or Uno
-Ultrasonic sensor HC-SR04
-2 push buttons
-Arduino relay modul
-3 LEDs(green,red,blue) If you want you can choose other colors
-some resistors (10k ohm)
-buzzer
-jumper wires
-breadboard
STEP 3: Connecting Ultrasonic Module
For this project I used ultrasonic module HC-SR04 because it is cheap and it is easy to work with.I bought it on internet for 3$.
So on this sensor you have 4 pins.
1.pin Vcc - this pin is connected to 5V+.
2.pin. Trig - you need to define this pin in your program.
3.pin Echo -this pin is the same as Trig you also need to define him.
4.pin GND - this pin is connected to ground.
How to define pin.In this case you need to define pins for Trig and Echo.I defined digital pin 7 for trigPin and digital pin 8 for echoPin.
If you want you can choose other digital pins from 2 to 53..(except 0 and 1)
You need to write this code before void setup (). (Watch step Code)
#define trigPin 7
#define echoPin 8
STEP 4: Wiring
When you are connecting pushbuttons you must connect resistor ( I used 10k ohm resistors) between GND and pushbutton.To ensure logical 0 on pushbutton.
Pushbutton (ON) is connected to digital pin 10
Pushbutton (OFF) is connected to digital pin 6
Buzzer is connected to digital pin 3
Red LED is connected to digital pin 4
Blue LED is connected to digital pin 5
Green LED is connected to digita pin 11
Relay is connected to digital pin 11
Wire for buzzer is firstly connected to relay module and then from relay to buzzer.I used NC contact on relay
STEP 5: Code
This is code for alarm.
Just download it, plug in Arduino and upload code.
6 Comments
blslvr5 5 years ago
Hi there
Can I use the S4A to code this? If so, please advise. Thank you!
Wan
iwoox 5 years ago
Sure you can. Just look at some tutorials on youtube. That is the quickest way to learn something fast.
Nematic! 7 years ago
I think insted of relay you sholud have used mosfet
iwoox 7 years ago
I will try with mosfet
RANDOM KNOWLEDGE 7 years ago
pleace explain and with SCHEMATICS instead of relay.
That would be awesome again.
tomatoskins 7 years ago
This is such a great project! You can use it for so many applications!