Smartage application

Dependencies:   BufferedSerial SX1276GenericLib USBDeviceHT mbed Crypto X_NUCLEO_IKS01A2

Fork of STM32L0_LoRa by Helmut Tschemernjak

Revision:
29:04e1489f8fe2
Child:
31:6bf5a868695f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hcsr04.cpp	Mon Sep 17 20:37:51 2018 +0000
@@ -0,0 +1,22 @@
+#include "hcsr04.h"
+#include "mbed.h"
+/*
+*HCSR04.cpp
+*/
+HCSR04::HCSR04(PinName t, PinName e) : trig(t), echo(e) {}
+ long HCSR04::echo_duration() {
+        
+    timer.reset();  //reset timer
+    trig=0;   // trigger low 
+    wait_us(2); //  wait 
+    trig=1;   //  trigger high
+    wait_us(10);
+    trig=0;  // trigger low
+         while(!echo); // start pulseIN
+      timer.start();
+     while(echo);
+      timer.stop();
+     return timer.read_us(); 
+ 
+}
+ 
\ No newline at end of file