I want to stop time delay function when ultrasonic sensor value is < 5cm. I cant use interrupt for this because ultrasonic sensor send digital signal. Here my code. here time delay function is, forward(); delay(4000); Actually I want to stop this forward function if sonar reading is <5cm before 4000ms
Any one have a idea what I have to do?
void loop {
if(angleDegrees -10 <headingDegrees && angleDegrees +10 >headingDegrees ) {
forward();
delay(4000);
}
if(safeZone>cm) {
Stop();
}
else {
search();
}
}