Purs ultrazvucni, lab 7

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
DudeHD
Date:
Thu Dec 06 18:08:44 2018 +0000
Commit message:
PURS Ultrazvucni

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	Thu Dec 06 18:08:44 2018 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+InterruptIn echo(p10);     
+DigitalOut led4(LED4);
+DigitalOut trig(p9);
+Timer echot;
+Serial pc(USBTX, USBRX);
+int ttt;
+float range=0;
+
+void tr() {
+        echot.start();
+}
+
+void tf(){
+        echot.stop();        
+        }
+
+int main() {
+    echo.rise(&tr);
+    echo.fall(&tf);
+    while(1){
+        trig=1;
+        wait_us(10);
+        trig=0;
+        ttt=echot.read_us();
+        range=ttt/58.0;
+        pc.printf("%f\n",range);
+        echot.reset();
+        wait_ms(50);
+        }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 06 18:08:44 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file