Library for the SRF05 Ultrasonic Rangefinder
Fork of SRF05 by
Revision 1:f7420569d67d, committed 2018-03-08
- Comitter:
- 15062200
- Date:
- Thu Mar 08 17:12:19 2018 +0000
- Parent:
- 0:e758665e072c
- Commit message:
- fixed srf05
Changed in this revision
RangeFinder.lib | Show annotated file Show diff for this revision Revisions of this file |
SRF05.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RangeFinder.lib Thu Mar 08 17:12:19 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/NickRyder/code/RangeFinder/#cf496fb70317
--- 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) {