Miya Miyagawa / Mbed 2 deprecated UltraSound_sensor

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
--- /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
--- /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
--- /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
--- /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