title: how to stop time delay function
body: <p>I want to stop time delay function when ultrasonic sensor value is &lt; 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 &lt;5cm before 4000ms</p>
  
  <p>Any one have a idea what I have to do? </p>
  
  <pre><code>void loop {
      if(angleDegrees -10 &lt;headingDegrees &amp;&amp; angleDegrees +10 &gt;headingDegrees  ) {
          forward();
          delay(4000);
      }
      if(safeZone&gt;cm) {
          Stop();
      }
      else {
          search();
      }
  }   
  </code></pre>