Match Lab
/
sample_HCSR04
demo program for HCSR04.
Conection
Diff: main.cpp
- Revision:
- 0:a982b6866f6c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Mar 29 09:59:44 2015 +0000 @@ -0,0 +1,15 @@ +#include "mbed.h" +#include "hcsr04.h" + +HCSR04 sensor(PB_8, PB_9); +Serial pc(USBTX, USBRX); + +int main() { + pc.baud(921600); + + while(1) { + sensor.start(); + wait_ms(100); + pc.printf("%dcm\n", sensor.get_dist_cm()); + } +}