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
Revision 0:835360b27a84, committed 2016-06-10
- Comitter:
- GuiguiZizouniet
- Date:
- Fri Jun 10 13:55:09 2016 +0000
- Commit message:
- Test distance
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 Fri Jun 10 13:55:09 2016 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+
+
+AnalogIn entree (A0);
+float prise, inverse_distance;
+int valeur_seuil_min=400;
+int valeur_seuil_max=500;
+
+
+
+float moyenne() {
+
+ float i=0;
+ float valeur, total, moyenne;
+
+ valeur=entree.read()*1000;
+
+ while(valeur>valeur_seuil_min) {
+ valeur=entree.read()*1000;
+ i=i+1;
+ total=total+valeur;
+ }
+ moyenne=total/i;
+ return moyenne;
+}
+
+
+
+int main() {
+ while(1) {
+ prise=entree.read()*1000;
+ if (prise>valeur_seuil_max);
+ inverse_distance=moyenne();
+ printf("%f\n", inverse_distance);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 10 13:55:09 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file