An example program for hcsr04 output to serial terminal

Dependencies:   HCSR04 mbed

Files at this revision

API Documentation at this revision

Comitter:
jonsmith
Date:
Tue Apr 28 20:57:27 2015 +0000
Commit message:
Sharing example HCSR04 project with serial output

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 ac4184adfe34 HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Tue Apr 28 20:57:27 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/prabhuvd/code/HCSR04/#71da0dbf4400
diff -r 000000000000 -r ac4184adfe34 main.cpp
--- /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
diff -r 000000000000 -r ac4184adfe34 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Apr 28 20:57:27 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file