Introduction: Arduino Security Alarm
Hi, this is my new arduino security alarm project. I made it with simple materials. An ultra sonic sensor, a led,buzzer,breadboard and my arduino. IF any object move there, the will glow and the buzzer starts beeping.This helps from robbery.This always alert you and little useful in our life.
Step 1: Materials Required:
1.An arduino board
2.a Breadboard
3.an ultrasonic sensor(HC-SR04)
4.a Led
5.a buzzer
6.Jumper cables
Step 2: Connect the Ultrasonic Sensor to the Breadboard:
connect the trigger pin to the digital pin 13
connect the eco pin to the digital pin 12
connect vcc to 5v
connect the gnd to the gnd pin
Step 3: Connect the LED and the Buzzer :
connect the cathode of the led to the anode of the buzzer,so you get one +ve and one -ve.
connect the +ve ends of those to the digital pin 10.
connect the -ve ends of those to the digital pin gnd
so you get the led and buzzer to be triggered.
Step 4: Coding......
copy and paste the code to your IDE:(dont worry about the led1)
#define trigPin 13
#define echoPin 12
#define led 11
#define led2 10
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT); }
void loop()
{ long duration, distance;
digitalWrite(trigPin, LOW);
// Added this line delayMicroseconds(2);
// Added this line digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000);
- Removed this line delayMicroseconds(10);
// Added this line digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 4) { // This is where the LED On/Off happens digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off digitalWrite(led2,LOW); } }





