Librería HCSR04 con algunas modificaciones

Dependents:   ZMOTO42

Revision:
0:d019c9870689
diff -r 000000000000 -r d019c9870689 HCSR043.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR043.h	Thu Dec 04 06:28:05 2014 +0000
@@ -0,0 +1,39 @@
+//Library for controlling ultrasonic module HCSR04
+//Ported by hiawoood from arduino library orgininally created by ITead studio.
+//Instantiate object by supplying the proper pin numbers of "trigger" and "echo"
+//e.g. 
+/*
+        int main() {
+            Ultrasonic sensor(p5, p6);
+            while(1){
+                long distance = sensor.distance(CM);
+                printf("Distance:%d\n");
+                wait(0.1);
+            }
+        }
+*/
+
+
+
+#ifndef HCSR043_H
+#define HCSR043_H
+
+#include "mbed.h"
+
+#define CM 1
+#define INC 0
+
+class HCSR043 {
+  public:
+    HCSR043(PinName t, PinName e);
+    long echo_duration();
+    long distance(int sys);
+
+    private:
+        DigitalOut trig;
+        DigitalIn echo;
+        Timer timer;
+        long duration,distacne_cm,distance_inc;
+};
+
+#endif
\ No newline at end of file