demo program for HCSR04.

Dependencies:   HCSR04 mbed

Conection

/media/uploads/Match314/hcsr04.bmp

Committer:
Match314
Date:
Sun Mar 29 09:59:44 2015 +0000
Revision:
0:a982b6866f6c
up

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Match314 0:a982b6866f6c 1 #include "mbed.h"
Match314 0:a982b6866f6c 2 #include "hcsr04.h"
Match314 0:a982b6866f6c 3
Match314 0:a982b6866f6c 4 HCSR04 sensor(PB_8, PB_9);
Match314 0:a982b6866f6c 5 Serial pc(USBTX, USBRX);
Match314 0:a982b6866f6c 6
Match314 0:a982b6866f6c 7 int main() {
Match314 0:a982b6866f6c 8 pc.baud(921600);
Match314 0:a982b6866f6c 9
Match314 0:a982b6866f6c 10 while(1) {
Match314 0:a982b6866f6c 11 sensor.start();
Match314 0:a982b6866f6c 12 wait_ms(100);
Match314 0:a982b6866f6c 13 pc.printf("%dcm\n", sensor.get_dist_cm());
Match314 0:a982b6866f6c 14 }
Match314 0:a982b6866f6c 15 }