demo program for HCSR04.

Dependencies:   HCSR04 mbed

Conection

/media/uploads/Match314/hcsr04.bmp

Files at this revision

API Documentation at this revision

Comitter:
Match314
Date:
Sun Mar 29 09:59:44 2015 +0000
Commit message:
up

Changed in this revision

HCSR04.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a982b6866f6c HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Sun Mar 29 09:59:44 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/prabhuvd/code/HCSR04/#71da0dbf4400
diff -r 000000000000 -r a982b6866f6c main.cpp
--- /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());
+    }
+}
diff -r 000000000000 -r a982b6866f6c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Mar 29 09:59:44 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file