Arduino UNO Ultrasonic Motion Alarm

by AnasArkawi in Circuits > Arduino

1420 Views, 19 Favorites, 0 Comments

Arduino UNO Ultrasonic Motion Alarm

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

Components

temp_206488752.jpg
Components:

Arduino UNO
Buzzer
Ultrasonic Sensor
Jumper Wire

Uploading the Code

temp_-736929710.jpg
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);
}

Ultrasonic Sensor Connections

temp_440944442.jpg
temp_2012443920.jpg
temp_-481811029.jpg
temp_1053655507.jpg
temp_-1241124482.jpg
Connections :

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

Connecting the Buzzer

temp_1088792215.jpg
temp_-1609253241.jpg
temp_739357279.jpg
temp_187555255.jpg
Connect Positive Terminal To Pin 8

Connect Negative Terminal To GND pin on POWER

Finish!!

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