// note ************* Disclaimer and Warning*************** dont copy paste any online site and youtube and other
// www.mobotics.us - shop no 3 Mobotics, View Estate, Law Gate Rd, Maheru, Punjab 144411 contact us 9878776520 9988226597
//designs by Tarjinder Tarun
//useing wokwi simulator https://wokwi.com/projects/364318121427340289
// do not use any site and youtube. only for students if use you are face copyright issue
// any facing ishu vist us
// www.mobotics.us
// This example code is in the public domain.
//https://mtforums.blogspot.com/ultrasonic-indicator-using-buzzer-and
#define trigPin 9
#define echoPin 8
#define buzzer 13
long duration;
float distanceInch;
int timer;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceInch = duration * 0.0133 /2;
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
timer = distanceInch * 10;
delay(timer);
}