Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HCSR04 by
Revision 1:ca0ff158918c, committed 2015-11-03
- Comitter:
- emiedema
- Date:
- Tue Nov 03 14:42:13 2015 +0000
- Parent:
- 0:86b2086be101
- Commit message:
- Awesome!
Changed in this revision
hcsr04.cpp | Show annotated file Show diff for this revision Revisions of this file |
hcsr04.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/hcsr04.cpp Mon Apr 14 08:23:09 2014 +0000 +++ b/hcsr04.cpp Tue Nov 03 14:42:13 2015 +0000 @@ -4,7 +4,7 @@ *HCSR04.cpp */ HCSR04::HCSR04(PinName t, PinName e) : trig(t), echo(e) {} - long HCSR04::echo_duration() { +float HCSR04::echo_duration() { timer.reset(); //reset timer trig=0; // trigger low @@ -21,7 +21,7 @@ } //return distance in cm -long HCSR04::distance(){ +float HCSR04::distance(){ duration = echo_duration(); distance_cm = (duration/2)/29.1 ; return distance_cm;
--- a/hcsr04.h Mon Apr 14 08:23:09 2014 +0000 +++ b/hcsr04.h Tue Nov 03 14:42:13 2015 +0000 @@ -37,14 +37,14 @@ class HCSR04 { public: HCSR04(PinName t, PinName e); - long echo_duration(); - long distance(); + float echo_duration(); + float distance(); private: DigitalOut trig; DigitalIn echo; Timer timer; - long duration,distance_cm; + float duration,distance_cm; }; #endif \ No newline at end of file