THEILOR LIROY
/
TP53
TP
Diff: main.cpp
- Revision:
- 0:08b3a1ec047a
diff -r 000000000000 -r 08b3a1ec047a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 16 17:38:33 2022 +0000 @@ -0,0 +1,64 @@ +#include "mbed.h" + +AnalogIn pot1(p19); // Potentiomètre 1 +AnalogIn pot2(p20); // Potentiomètre 2 + +Timer Tcalcul,Taffichage ; // Timer +int a, b ; // Compteur + +float ReadPot1=0, ReadPot=0, Moy1=0,Moy=0; + +// Fonction lecture des potentiometres + +void LecturePot() +{ + ReadPot1 = ReadPot1+ pot1.read(); + ReadPot2 = ReadPot2+ pot2.read(); + a++; + b++; +} + + +// Fonction de calcul des potentiometres + +void Moyenne() +{ + Tcalcul.start(); + + Moy1= ReadPot1/a; + Moy2= ReadPot2/b; + + Tcalcul.stop(); + +} + + + +// Fonction d'affichage des moyennes +void Affichage() +{ + Taffichage.start(); + lcd.cls(); + lcd.printf("MoyennePot1: %f MoyennePot2: %f ",Moy1,Moy2); + lcd.printf("Temps de calcul : %f Temps d'affichage: %f",Tcalcul,Taffichage); + + Taffichage.stop(); + +} + + + + +int main() +{ + while(1) + { + LecturePot(); + Moyenne(); + Affichage(); + } + + + + +} \ No newline at end of file