tyonpa

Dependencies:   mbed HCSR04

Files at this revision

API Documentation at this revision

Comitter:
ec30109b
Date:
Fri Jun 07 05:07:15 2019 +0000
Commit message:
urtrasonic

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Fri Jun 07 05:07:15 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/prabhuvd/code/HCSR04/#71da0dbf4400
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 07 05:07:15 2019 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+#include "hcsr04.h"
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+HCSR04 usensor(D4, D6); // Trigger(DO), Echo(PWMIN)
+
+DigitalOut led(D2);
+
+int main()
+{
+    pc.printf("Start!\n\r");
+    while(1) {
+        usensor.start();
+        unsigned int dist = usensor.get_dist_cm();
+        pc.printf("cm:%ld\r\n",dist );
+        
+        if(dist >= 20 && dist <= 60){
+            led = 1;
+        }else{
+            led = 0;
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jun 07 05:07:15 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file