S6 Makerspace (Distance Alarm)
by Enzo2016BR in Circuits > Gadgets
228 Views, 2 Favorites, 0 Comments
S6 Makerspace (Distance Alarm)
![Arduino.jpg](/proxy/?url=https://content.instructables.com/FCI/BJMQ/JOONQC1B/FCIBJMQJOONQC1B.jpg&filename=Arduino.jpg)
We did a Distance Sensor, that buzzes when anything is 15 cm close to the Distance Sensor, the use of our project is when you need privacy on your room, when someone enter your room, the buzzer is going to Buzz.
Add the Coding on the Arduino Board
Coding:
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);
}
}
Materials Used:
- An Arduino Board
- A Buzzer (5-Volt)
- A Distance Sensor
- 6 Female & 6 Male Wires
- The Arduino Programs
Copy the Image Below Using the Correct Materials
![BUZZER.png](/proxy/?url=https://content.instructables.com/F94/MT10/JOONQBBI/F94MT10JOONQBBI.png&filename=BUZZER.png)