int maximumRange =100;
int minimumRange =00;
long duration, distance;
#define LEDPin 12
#define ECHO_PIN 10
#define TRIG_PIN 11
#define buzzer 13
void setup(){
Serial.begin(9600);
pinMode(LEDPin, OUTPUT);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(buzzer, OUTPUT);
}
void loop(){
digitalWrite(buzzer, HIGH);
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration= pulseIn(ECHO_PIN, HIGH)
distance duration/58.2;
if (distance >= maximumRange || distance <= minimRange)
{
digitalWrite(LEDPin, HIGH);
digitalWrite(buzzer, LOW);
}
else {
digitalWrite(LEDPin, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
}