Library used to operate the HCSR04 Ranging Module used in our project.

Fork of HCSR04 by Awadh Al Shukaili

Files at this revision

API Documentation at this revision

Comitter:
Jakschwa
Date:
Fri Apr 29 01:56:57 2016 +0000
Parent:
0:0bda99bb39a4
Commit message:
1_Project3_Robot1_Final

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	Tue Oct 18 14:32:12 2011 +0000
+++ b/HCSR04.cpp	Fri Apr 29 01:56:57 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;
 }
 
--- a/HCSR04.h	Tue Oct 18 14:32:12 2011 +0000
+++ b/HCSR04.h	Fri Apr 29 01:56:57 2016 +0000
@@ -27,7 +27,7 @@
   public:
     HCSR04(PinName t, PinName e);
     long echo_duration();
-    long distance(int sys);
+    long distance();
 
     private:
         DigitalOut trig;