l

Dependencies:   mbed Pulse LM61CIZ

Files at this revision

API Documentation at this revision

Comitter:
Ryosei
Date:
Mon Sep 02 12:47:53 2019 +0000
Commit message:
k;

Changed in this revision

LM61CIZ.lib Show annotated file Show diff for this revision Revisions of this file
Pulse.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 a183af1b1216 LM61CIZ.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM61CIZ.lib	Mon Sep 02 12:47:53 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_Cookbook_SE/code/LM61CIZ/#3635002dc1de
diff -r 000000000000 -r a183af1b1216 Pulse.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pulse.lib	Mon Sep 02 12:47:53 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/NickRyder/code/Pulse/#fb79a4637a64
diff -r 000000000000 -r a183af1b1216 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 02 12:47:53 2019 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "Pulse.h"
+#include "LM61CIZ.h"
+#define echoPin D4
+#define trigPin D5
+#define TempPin A0
+
+Serial pc(USBTX,USBRX);
+AnalogIn temptemp(A0);
+PulseInOut echo(echoPin);
+PulseInOut trig(trigPin);
+LM61CIZ Temp(TempPin);
+
+long map(long x, long in_min, long in_max, long out_min, long out_max) {
+  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
+}
+
+double Duration = 0;
+double Distance=0;
+
+
+int main(){
+    pc.baud(9600);
+    while(1){
+        int temp=Temp.getTemperature();
+        trig.write_us(1,10);
+        Duration=echo.read_high_us(5000);
+        if(Duration>0){
+            Duration=Duration/2;
+            double sspead=331.5+0.6*temp;
+            Distance=Duration*sspead*100/1000000;
+            pc.printf("%d  %lfm\n",temp,Distance);
+        }
+        wait(0.01);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r a183af1b1216 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 02 12:47:53 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file