Marvas / HCSR04

Files at this revision

API Documentation at this revision

Comitter:
marvas
Date:
Mon May 06 12:32:07 2019 +0000
Parent:
0:86b2086be101
Commit message:
hcsr04 ultrasonik sensor

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	Mon May 06 12:32:07 2019 +0000
@@ -4,7 +4,7 @@
 *HCSR04.cpp
 */
 HCSR04::HCSR04(PinName t, PinName e) : trig(t), echo(e) {}
- long HCSR04::echo_duration() {
+ int HCSR04::echo_sure() {
         
     timer.reset();  //reset timer
     trig=0;   // trigger low 
@@ -21,9 +21,9 @@
 }
  
 //return distance in cm 
-long HCSR04::distance(){
-    duration = echo_duration();
-  distance_cm = (duration/2)/29.1  ;
-        return distance_cm;
+int HCSR04::mesafe(){
+    sure = echo_sure();
+  mesafe_cm = (sure/2)/29.1  ;
+        return mesafe_cm;
 
 }
\ No newline at end of file
--- a/hcsr04.h	Mon Apr 14 08:23:09 2014 +0000
+++ b/hcsr04.h	Mon May 06 12:32:07 2019 +0000
@@ -37,14 +37,14 @@
 class HCSR04 {
   public:
     HCSR04(PinName t, PinName e);
-    long echo_duration();
-    long distance();
+    int echo_sure();
+    int mesafe();
  
     private:
         DigitalOut trig;
         DigitalIn echo;
         Timer timer;
-        long duration,distance_cm;
+        int sure,mesafe_cm;
 };
  
 #endif
\ No newline at end of file