Motion Detecting Buzzer
![Screenshot 2023-05-24 at 11.54.05 AM.png](/proxy/?url=https://content.instructables.com/FGL/KYEC/LI1YFUJL/FGLKYECLI1YFUJL.png&filename=Screenshot 2023-05-24 at 11.54.05 AM.png)
![Screenshot 2023-05-22 at 11.23.17 AM.png](/proxy/?url=https://content.instructables.com/FOV/HFYH/LI1YFSTQ/FOVHFYHLI1YFSTQ.png&filename=Screenshot 2023-05-22 at 11.23.17 AM.png)
![Screenshot 2023-05-22 at 11.16.44 AM.png](/proxy/?url=https://content.instructables.com/F92/DKZH/LI1YFSYG/F92DKZHLI1YFSYG.png&filename=Screenshot 2023-05-22 at 11.16.44 AM.png)
![Screenshot 2023-05-24 at 11.38.49 AM.png](/proxy/?url=https://content.instructables.com/FYO/T0EU/LI1YFT0T/FYOT0EULI1YFT0T.png&filename=Screenshot 2023-05-24 at 11.38.49 AM.png)
I made a motion detecting buzzer. When the ultrasonic sensor detects motion inside a certain range, it sends a signal to the Arduino. The Arduino then sends a signal to the buzzer to play a noise. It plays the noise until the ultrasonic sensor doesn't detect anything.
Downloads
Supplies
Arduino Uno R3, breadboard, Ultrasonic sensor HC-SR04, Buzzer, 9v battery and connector, and 9 male to male wires.
TinkerCad Circuit Design
![Screenshot 2023-05-22 at 11.16.44 AM.png](/proxy/?url=https://content.instructables.com/FN1/32MZ/LI1YFT8C/FN132MZLI1YFT8C.png&filename=Screenshot 2023-05-22 at 11.16.44 AM.png)
On TinkerCad, https://www.tinkercad.com, place the following items, Arudino Uno R3, breadboard, Ultrasonic sensor HC-SR04, Buzzer, 9v battery and connector, and 9 male to male wires. Connect them as the photo shows.
Circuit Code
![Screenshot 2023-05-24 at 11.38.49 AM.png](/proxy/?url=https://content.instructables.com/FQR/992O/LI1YFTF3/FQR992OLI1YFTF3.png&filename=Screenshot 2023-05-24 at 11.38.49 AM.png)
Place the code blocks in the order as shown.
This is the digital text code:
// C++ code
//
int distance = 0;
long readUltrasonicDistance(int triggerPin, int echoPin)
{
pinMode(triggerPin, OUTPUT); // Clear the trigger
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
// Sets the trigger pin to HIGH state for 10 microseconds
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
// Reads the echo pin, and returns the sound wave travel time in microseconds
return pulseIn(echoPin, HIGH);
}
int counter;
void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
}
void loop()
{
distance = 0;
for (counter = 0; counter < 100000000000000; ++counter) {
distance = 0.01723 * readUltrasonicDistance(2, A1);
delay(20); // Wait for 20 millisecond(s)
Serial.println(distance);
if (distance < 150) {
tone(8, 523, 50); // play tone 60 (C5 = 523 Hz)
}
}
}
Physical Circuit
![Screenshot 2023-05-22 at 11.23.17 AM.png](/proxy/?url=https://content.instructables.com/FYS/W3J1/LI1YFTP1/FYSW3J1LI1YFTP1.png&filename=Screenshot 2023-05-22 at 11.23.17 AM.png)
![Screenshot 2023-05-24 at 11.51.00 AM.png](/proxy/?url=https://content.instructables.com/FPD/07RQ/LI1YFTPX/FPD07RQLI1YFTPX.png&filename=Screenshot 2023-05-24 at 11.51.00 AM.png)
![Screenshot 2023-05-24 at 11.54.05 AM.png](/proxy/?url=https://content.instructables.com/FMK/19BP/LI1YFTSU/FMK19BPLI1YFTSU.png&filename=Screenshot 2023-05-24 at 11.54.05 AM.png)
With all the resources in hand, copy what you did on TinkerCad in real life.
Final Product
![Screenshot 2023-05-24 at 12.03.39 PM.png](/proxy/?url=https://content.instructables.com/FDV/ESOZ/LI1YFU31/FDVESOZLI1YFU31.png&filename=Screenshot 2023-05-24 at 12.03.39 PM.png)
![Screenshot 2023-05-24 at 12.16.07 PM.png](/proxy/?url=https://content.instructables.com/FIL/GORN/LI1YFUPB/FILGORNLI1YFUPB.png&filename=Screenshot 2023-05-24 at 12.16.07 PM.png)
Download the Arudino IDE software at https://www.arduino.cc/en/software . Plug in the code from TinkerCad into the software. Load in the code on the right that is in text. You can get to that screen by selecting blocks and text. Confirm the code works. Plug your Arduino in, then upload the code. If you do all the steps correctly your final product will be a working motion detecting buzzer.