DP

Dependencies:   FastAnalogIn mbed-rtos mbed

Revision:
0:f3b355df6f26
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ultrasonic.h	Sun Apr 26 13:14:02 2015 +0000
@@ -0,0 +1,35 @@
+#ifndef _ULTRASONIC_H
+#define _ULTRASONIC_H
+
+#include "mbed.h"
+#include "rtos.h"
+
+class cUltrasonic {
+    public:     
+        cUltrasonic(PinName pinEcho, PinName pinTrig);
+        
+        /* This method set trigger */
+        void setTrig();
+        
+        /* This method returns width of received pulse*/
+        int getPulseWidth();
+        
+        /* Pointer to thread*/
+        Thread* thread;
+    
+    private:
+        DigitalOut trig;
+        InterruptIn echo;
+        
+        Timer timer;
+        float pulseWidth;
+        
+        /* ISR of rising edge */
+        void riseEdge(void);
+        
+        /* ISR of falling edge*/
+        void fallEdge(void);
+    
+
+};
+#endif
\ No newline at end of file