Works with interrupts

Fork of HC_SR04_Ultrasonic_Library by EJ Teb

Revision:
5:36fcbbb149d8
Parent:
4:e0f9c9fb4cf3
--- a/ultrasonic.cpp	Mon Nov 24 20:23:07 2014 +0000
+++ b/ultrasonic.cpp	Tue Dec 26 09:28:16 2017 +0000
@@ -4,6 +4,7 @@
     {
         _updateSpeed = updateSpeed;
         _timeout = timeout;
+        _t.start ();
     }
     
     ultrasonic::ultrasonic(PinName trigPin, PinName echoPin, float updateSpeed, float timeout, void onUpdate(int))
@@ -16,11 +17,13 @@
     }
     void ultrasonic::_startT()
     { 
+        //printf("Start2: %d\n", _t.read());
         if(_t.read()>600)
         {
             _t.reset ();
         }
         start = _t.read_us ();
+        //printf("Start: %d\n", start);
     }
         
     void ultrasonic::_updateDist()