Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Pulse LM61CIZ
Revision 0:a183af1b1216, committed 2019-09-02
- Comitter:
- Ryosei
- Date:
- Mon Sep 02 12:47:53 2019 +0000
- Commit message:
- k;
Changed in this revision
--- /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