Library for the SRF05 Ultrasonic Rangefinder

Dependencies:   RangeFinder

Fork of SRF05 by Simon Ford

Revision:
1:f7420569d67d
Parent:
0:e758665e072c
--- a/SRF05.cpp	Fri Nov 19 22:34:56 2010 +0000
+++ b/SRF05.cpp	Thu Mar 08 17:12:19 2018 +0000
@@ -27,15 +27,16 @@
     : _trigger(trigger), _echo(echo) {    
         
     // Attach interrupts
-    _echo.rise(this, &SRF05::_rising);
-    _echo.fall(this, &SRF05::_falling);
-    _ticker.attach(this, &SRF05::_startRange, 0.1);     
+    _echo.rise(callback(this,&SRF05::_rising));
+    _echo.fall(callback(this,&SRF05::_falling));
+    _ticker.attach(callback(this,&SRF05::_startRange), 0.1);
 }
   
 void SRF05::_startRange() {
     // send a trigger pulse, 20uS long
     _trigger = 1;
-    wait (0.000002);
+    //wait (0.000002);
+    wait_us(40);
     _trigger = 0;
 }
 
@@ -49,6 +50,7 @@
 void SRF05::_falling(void) {
     _timer.stop();
     _dist = _timer.read_us()/58.0;
+    _dist=99.0;
 }
 
 float SRF05::read(void) {