Introduction: Arduino UNO Ultrasonic Motion Alarm

Picture of Arduino UNO Ultrasonic Motion Alarm

How to make arduino powered motion alarm!
I Hope You Enjoy

Step 1: Components

Picture of Components

Components:

Arduino UNO
Buzzer
Ultrasonic Sensor
Jumper Wire

Step 2: Uploading the Code

Picture of Uploading the Code

CODE :

#define trigPin 12
#define echoPin 13
int Buzzer = 8;

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(Buzzer, OUTPUT);
}

void loop() {
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance >= 80 || distance Serial.println("no object detected");
digitalWrite(Buzzer, LOW);

}
else {
Serial.println("object detected");
tone(Buzzer, 400); // play 400 Hz tone for 500 ms
delay(500);
tone(Buzzer, 800); // play 800Hz tone for 500ms
delay(500);
tone(Buzzer, 400); // play 400 Hz tone for 500 ms
delay(500);
tone(Buzzer, 800); // play 800Hz tone for 500ms
delay(500);
tone(Buzzer, 400); // play 400 Hz tone for 500 ms
delay(500);
tone(Buzzer, 800); // play 800Hz tone for 500ms
delay(500);
noTone(Buzzer);
}
delay(300);
}

Step 3: Ultrasonic Sensor Connections

Picture of Ultrasonic Sensor Connections

Connections :

Connect Vcc to Vin pin
Connect GND to GND
connect ECHO to Pin 13
connect TRİG to Pin 12

Step 4: Connecting the Buzzer

Picture of Connecting the Buzzer

Connect Positive Terminal To Pin 8

Connect Negative Terminal To GND pin on POWER

Step 5: Finish!!

Picture of Finish!!

Now Power Up Arduino And Test It, Don't Forget To Vote, I Hope You Enjoy Thanks For Supporting Goodbye ?

Comments

harshvardhanraj37 (author)2017-06-30

code is not working