demo program for HCSR04.

Dependencies:   HCSR04 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "hcsr04.h"
00003 
00004 HCSR04 sensor(PB_8, PB_9);
00005 Serial pc(USBTX, USBRX);
00006 
00007 int main() {
00008     pc.baud(921600);
00009     
00010     while(1) {
00011         sensor.start();
00012         wait_ms(100); 
00013         pc.printf("%dcm\n", sensor.get_dist_cm());
00014     }
00015 }