Basic distance test from ultraSonic sensor

Dependencies:   HCSR04 mbed

Files at this revision

API Documentation at this revision

Comitter:
joshwilkins2013
Date:
Tue Mar 31 22:39:10 2015 +0000
Commit message:

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 1fa203f27322 HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Tue Mar 31 22:39:10 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/antoniolinux/code/HCSR04/#86b2086be101
diff -r 000000000000 -r 1fa203f27322 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 31 22:39:10 2015 +0000
@@ -0,0 +1,13 @@
+#include "mbed.h"
+#include "hcsr04.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+HCSR04 sensor(A3,A2); // Trigger , Echo
+int main(){
+    pc.baud(9600);
+    while(1){
+        long distance = sensor.distance();   
+        pc.printf("distance  %d  \n",distance);
+        wait(1.0); // 1 sec  
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 1fa203f27322 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 31 22:39:10 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file