Introduction: Distance Sensor With 5V Buzzer

This is a sensor that will buzz whenever it detects something in a 15cm range.

Step 1: Reason for Why We Chose This Idea

The idea of our group was to create a buzzer that acted together with a distance sensor. The reason we did this was because all of the members in our group had privacy problems at their home, like for example people just barging into our rooms while we weren’t in it. So we did the buzzer so that it would be able to alarm us whenever we were out of the room and someone went in it without your clearance or a reason.

Step 2: Materials

The materials used for our project were:

- An Arduino Board

- A Buzzer (5-Volt)

- A Distance Sensor

- Male & Female Wires

- The Arduino Program

Step 3: The Coding

This is the coding we used for a distance sensor that sensed anything 15 cm away, and when it sensed it would buzz, a friends from another project helped me and my group on the coding because he was really good at it, and he knew everything that he was doing:

int duration:

int distance:

int const trigPin = 9;

int const echoPin = 10;

int buzzer = 2;

void setup( ){

pinMode(trigPin , OUTPUT);

pinMode( echoPin , INPUT);

pinMode( buzzer , OUTPUT);

}

void loop( ){

digitalWrite(trigPin, HIGH);

delay(2); digitalWrite

(trigPin, LOW);

duration = pulseIn

(echoPin , HIGH);

distance = (duration * 0.034)/2; if(distance < 15){

digitalWrite(2, HIGH);

}

else{ digitalWrite(2, LOW);

}

}

Step 4: Ways You Can Do This

Me and my group worked on this project without using a breadboard, because we didn't have one, we only used the arduino board, but obviously if you have a breadboard available you'll be able to use it.