I found from a site. I have a question regarding to programming.. I am wondering what happened more than 151 negative number of distance? if 150 - 151(151 is convert distance number) will be negative 1. because it said delay(150 - distance); , so will it work if delay(-1) function?
here example code...
void buzzer(){
if (distance>1){
if(distance>100){ // continuous sound if the obstacle is too close
digitalWrite(11,HIGH);
}
else{ // beeps faster when an obstacle approaches
digitalWrite(11,HIGH);
delay(150-distance); // adjust this value for your convenience
digitalWrite(11,LOW);
delay(150-distance); // adjust this value for your convenience
}
}
else{ // off if there is no obstacle
digitalWrite(11,LOW);
}
}