Jon Smith
/
mbed_hcsr04
An example program for hcsr04 output to serial terminal
Diff: main.cpp
- Revision:
- 0:ac4184adfe34
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 28 20:57:27 2015 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "hcsr04.h" + +DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); + +HCSR04 usensor(p25,p6); + +unsigned int dist; +int main() +{ + + while(1) { + usensor.start(); + wait_ms(500); + dist=usensor.get_dist_cm(); + + pc.printf("cm:%ld\r\n",dist ); + + } +} \ No newline at end of file