demo program for HCSR04.

Dependencies:   HCSR04 mbed

Conection

/media/uploads/Match314/hcsr04.bmp

main.cpp

Committer:
Match314
Date:
2015-03-29
Revision:
0:a982b6866f6c

File content as of revision 0:a982b6866f6c:

#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());
    }
}