Library used to implement HCSR04 Ranging Module.

Dependents:   2Project3_Robot2_Final

Fork of HCSR04 by Awadh Al Shukaili

Files at this revision

API Documentation at this revision

Comitter:
Jakschwa
Date:
Mon May 02 17:22:54 2016 +0000
Parent:
0:0bda99bb39a4
Commit message:
This library was used to implement the HCSR04 ranging module used to sense distances in our Multi-Robot Security System Project in IUPUI's ECE 59500 Embedded Systems Design course.

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	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;
 }
 
--- a/HCSR04.h	Tue Oct 18 14:32:12 2011 +0000
+++ b/HCSR04.h	Mon May 02 17:22:54 2016 +0000
@@ -27,7 +27,7 @@
   public:
     HCSR04(PinName t, PinName e);
     long echo_duration();
-    long distance(int sys);
+    long distance();
 
     private:
         DigitalOut trig;