Library used to implement HCSR04 Ranging Module.

Dependents:   2Project3_Robot2_Final

Fork of HCSR04 by Awadh Al Shukaili

Revision:
1:348fdd74f030
Parent:
0:0bda99bb39a4
--- a/HCSR04.cpp	Tue Oct 18 14:32:12 2011 +0000
+++ b/HCSR04.cpp	Mon May 02 17:22:54 2016 +0000
@@ -27,15 +27,12 @@
 //return distance to nearest obstacle or returns -1 
 //if no obstacle within range
 //set sys to cm or inch accordingly
-long HCSR04::distance(int sys){
+long HCSR04::distance(void){
     duration = echo_duration();
     if(duration > 30000)
-        return -1;
+        return 1000;
     distacne_cm = duration /29 / 2 ;
     distance_inc = duration / 74 / 2;
-    if (sys)
-        return distacne_cm;
-    else
-        return distance_inc;
+    return distacne_cm;
 }