Anjali Shaw
Published © GPL3+

Radar using buzzer

You can actually stimulate the buzzer when something is detected in the given range of ultrasonic detector

BeginnerFull instructions provided30 minutes184
Radar using buzzer

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

this is circuit diagram

as this one is generated on internet I'm not able to show you the connected servo an ultrasonic sensor.The end base of sensor is connected on blades of servo by means of soft glue or any other thing you want.

Code

buzzer_servo motor_ultrasonic sensor

Arduino
you can directly copy-paste the code or rewrite in IDE for better understanding
#include<Servo.h>

int trig =10;
int echo=9;
int buzzer=2;

Servo myservo;

void setup() 
{
  // put your setup code here, to run once:
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
pinMode(buzzer,OUTPUT);
myservo.attach(11);
Serial.begin(9600);

}

void loop() 
{
  // put your main code here, to run repeatedly:
for(int i=0;i<180;i++)
{
  myservo.write(i);
  delay(30);
  if (calc_dis()<=50 && calc_dis()>=5)
  {
    Serial.print("distance-");
    Serial.print(calc_dis());
    digitalWrite(buzzer,HIGH);
    delay(1000);
    Serial.print(">>");
    Serial.print(buzzer);
  }
  
}
for(int i=180;i>0;i--)
{
  myservo.write(i);
  delay(30);
  if (calc_dis()<=50 && calc_dis()>=5)
  {
    Serial.print("distance-");
    Serial.print(calc_dis());
    digitalWrite(buzzer,HIGH);
    delay(1000);
    Serial.print(">>");
    Serial.print(buzzer);
  }
  
}
delay(60);
}
int calc_dis()
{
  int distance;
  int duration;
  digitalWrite(trig,HIGH);
  delay(1);
  digitalWrite(trig,LOW);
  
  duration=pulseIn(echo,HIGH);
  
  distance=(duration/2)/29.1;
  return distance;
}

Credits

Anjali Shaw

Anjali Shaw

8 projects • 0 followers

Comments