Mesure sur 1 seconde avec moyenneage

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
the420team
Date:
Tue May 22 07:37:57 2018 +0000
Commit message:
Programme detection aboiement moyenne 1 s

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
diff -r 000000000000 -r 14c42a61cdb2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 22 07:37:57 2018 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+
+Serial pc (USBTX, USBRX);
+AnalogIn ain(p17); 
+DigitalOut led(p7);
+
+float f ;
+float silence = 1.1 ;
+float max = 1.7 ;
+int niveau = 0 ;
+int tableau [100];
+int i;
+int k;
+int moyenne  = 0;
+char c ;
+
+void acquisition()
+{
+         f=3.3*ain.read();
+         niveau = 100* (f-silence)/max ;
+         tableau[k]= niveau ;
+         k++ ;
+         if (k ==100)
+         {k =0 ;}
+}
+
+
+int moyAboiement()
+{int somme = 0 ;
+int moyenne = 0 ;
+for (i=0;i<100; i++)
+{
+somme = somme + tableau[i];
+}
+moyenne  = somme /100 ;
+
+return moyenne ;
+}
+
+
+int main() {
+     Ticker horloge; 
+     horloge.attach(&acquisition, 0.01);
+     while(1)
+    {    
+      printf("\nSaisir A pour connaitre niveau aboiement \n\r");
+      c = pc.getc() ;
+      if (c=='A')
+      {moyenne = moyAboiement() ;
+       printf("Niveau aboiement sur 1s = %d \n\r", moyenne );
+       }
+      
+    }
+}
diff -r 000000000000 -r 14c42a61cdb2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue May 22 07:37:57 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file