ER2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dorian06
Date:
Wed Jun 02 07:24:41 2021 +0000
Commit message:
capt

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
diff -r 000000000000 -r a6e925f144a4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 02 07:24:41 2021 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+AnalogOut trig(p16);
+InterruptIn Echo(p15);
+Timer T1;
+Ticker T2;
+void Trig(void);
+void FM(void);
+void FD(void);
+float temp;
+int main()
+{
+    T2.attach(&Trig,1);
+    float dis;
+    Echo.rise(&FM);
+    Echo.fall(&FD);
+    while(1) {
+        dis =17/(100*temp);
+        printf("cm=%g\n\r",dis);
+
+
+    }
+}
+
+void Trig(void)
+{
+    trig=1;
+    wait_us(50);
+    trig=0;
+}
+void FM(void)
+{
+    T1.stop();
+    T1.reset();
+    T1.start();
+}
+void FD(void)
+{
+    T1.stop();
+    temp=T1.read();
+}
\ No newline at end of file
diff -r 000000000000 -r a6e925f144a4 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jun 02 07:24:41 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file