changed range conditions

Dependents:   theRobot3

Fork of HCSR04 by stephen smitherman

Files at this revision

API Documentation at this revision

Comitter:
Fairy_Paolina
Date:
Tue Apr 15 16:51:11 2014 +0000
Parent:
2:3ebde19131af
Commit message:
changed range;

Changed in this revision

HCSR04.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3ebde19131af -r 89f21eb28e13 HCSR04.cpp
--- a/HCSR04.cpp	Thu Dec 12 17:22:48 2013 +0000
+++ b/HCSR04.cpp	Tue Apr 15 16:51:11 2014 +0000
@@ -67,6 +67,9 @@
     
         rRangeMeters = (float)dTime_us * SPEED_OF_SOUND / 2000000.0 * MTRS_TO_INCH;
         status = RANGE_MEAS_INVALID;
+        
+        if(rRangeMeters > 200 || rRangeMeters < 3 ) return RANGE_MEAS_INVALID;
+        
         return RANGE_MEAS_VALID;
     }else{