corentin le nel / Mbed 2 deprecated distance

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
corentinlenel
Date:
Sun Dec 23 18:08:03 2018 +0000
Commit message:
Test du capteur de distance MS-EZ4.

Changed in this revision

header.h 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
source.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 01d408baf267 header.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/header.h	Sun Dec 23 18:08:03 2018 +0000
@@ -0,0 +1,3 @@
+#include "mbed.h"
+
+void test(void);
\ No newline at end of file
diff -r 000000000000 -r 01d408baf267 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 23 18:08:03 2018 +0000
@@ -0,0 +1,9 @@
+#include "header.h"
+
+int main() 
+{
+    while(1) 
+    {
+        test();
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 01d408baf267 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 23 18:08:03 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file
diff -r 000000000000 -r 01d408baf267 source.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source.cpp	Sun Dec 23 18:08:03 2018 +0000
@@ -0,0 +1,22 @@
+#include "header.h"
+
+AnalogIn sonar(p16);
+BusOut leds(LED1, LED2, LED3, LED4);
+
+void test(void)
+{
+    float mesure1, mesure2;
+    
+    mesure1 = sonar.read();
+    wait(0.5);
+    mesure2 = sonar.read();
+    
+    if (abs(mesure1 - mesure2) < 0.1f)
+    {
+        leds = 15;
+    }
+    else
+    {
+        leds = 0;
+    }
+}
\ No newline at end of file