mbedを用いた制御学生の制御 / Mbed 2 deprecated SONIC

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
WAT34
Date:
Sat Dec 20 01:05:52 2014 +0000
Commit message:
HCSR04;

Changed in this revision

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/main.cpp	Sat Dec 20 01:05:52 2014 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+Timer t;
+DigitalOut led(LED1);
+DigitalOut trig(p21);
+DigitalIn echo(p22);
+Serial pc(USBTX,USBRX);
+
+int main(){
+    double so;
+    led = 0;
+    while(1){
+        t.reset();
+        trig = 1;
+        so = 0;
+        wait_us(10);
+        trig = 0;
+        if(echo == 1){
+            t.start();
+            while(1){
+                if(echo == 0){
+                    t.stop();
+                    so = t.read();
+                    so = (so/2.0)*34000.0;
+                    pc.printf("%lf\n\r",so);
+                    break;
+                }
+            }
+        }
+        led != led ;
+    }
+}    
+        
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Dec 20 01:05:52 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file