Smartage application
Dependencies: BufferedSerial SX1276GenericLib USBDeviceHT mbed Crypto X_NUCLEO_IKS01A2
Fork of STM32L0_LoRa by
Diff: hcsr04.cpp
- Revision:
- 31:6bf5a868695f
- Parent:
- 29:04e1489f8fe2
--- a/hcsr04.cpp Mon Sep 17 20:39:50 2018 +0000 +++ b/hcsr04.cpp Mon Sep 17 20:42:51 2018 +0000 @@ -19,4 +19,12 @@ return timer.read_us(); } + +//return distance in cm +long HCSR04::distance(){ + duration = echo_duration(); + distance_cm = (duration/2)/29.1 ; + return distance_cm; + +} \ No newline at end of file