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.
Diff: main.cpp
- Revision:
- 1:a18a07e03e7d
- Parent:
- 0:0fb169e1b9b4
- Child:
- 2:1303607f8777
--- a/main.cpp Thu Sep 14 17:59:07 2017 +0000 +++ b/main.cpp Thu Sep 14 19:40:00 2017 +0000 @@ -1,12 +1,35 @@ #include "mbed.h" -DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); + +AnalogIn ain(p15); + +Ticker display; +int i=0; +int Nouvelle_moyenne; +int Ancienne_moyenne = 0; +unsigned short Tableau_Moyenne[5]={0,0,0,0,0}; + +void lire_Info(){ + i = i%5; + + Tableau_Moyenne[i] = ain.read_u16(); //= LIRE PATTE 8 ; + i++; + Nouvelle_moyenne = (int)Tableau_Moyenne[0]+(int)Tableau_Moyenne[1]+(int)Tableau_Moyenne[2]+(int)Tableau_Moyenne[3]+(int)Tableau_Moyenne[4]; + if((Ancienne_moyenne - Nouvelle_moyenne) > 40960 || (Nouvelle_moyenne - Ancienne_moyenne) > 40960){ + //Detection dun evenement + pc.printf("Evenement detectee \n\r"); + } + Ancienne_moyenne = Nouvelle_moyenne; +} int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + pc.printf("Debut prog"); + display.attach(&lire_Info, 0.250); + while(1){ + } } + + +