Guillaume Alli
/
TP7_IUT_NICE
Programme TP3
Revision 7:e906470d40b9, committed 2021-11-10
- Comitter:
- Agachon
- Date:
- Wed Nov 10 16:55:03 2021 +0000
- Parent:
- 6:69101b9b0c17
- Commit message:
- updated Exo3
Changed in this revision
Exo2.cpp | Show diff for this revision Revisions of this file |
Exo3.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 69101b9b0c17 -r e906470d40b9 Exo2.cpp --- a/Exo2.cpp Wed Nov 10 16:51:26 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -//#define Exo2 -#ifdef Exo2 - -#include "mbed.h" -#include "info1.h" - -#define LOW 0 -#define HIGH 1 - -//pour le debug (printf & scanf) -Serial pc(USBTX, USBRX); - -int main(void) -{ - //Declaration des variables : - int etat; - int bp,bp1,bp2; - - PwmOut ledB(LED_BLUE); - PwmOut ledG(LED_GREEN); - PwmOut ledR(LED_RED); - //Initialisation - etat=0; - - ledB.period_us(100); - ledG.period_us(100); - ledR.period_us(100); - - //Boucle infinie - while (1) { - //Lecture du slider (bp=1 si doigt sur slider, 0 sinon) - appui_num(&bp); - appui_ana(&bp1,&bp2,0.5); - - - //Determination de l'etat en fonction de BP - switch(etat) - { - case 0: - if (bp==HIGH) - etat =1; break; - case 1: - if (bp==LOW) - etat =2; break; - case 2: - if (bp==HIGH) - etat =3; break; - case 3: - if (bp==LOW) - etat =0; break; - } - - //Ecriture sur les sorties en fct de l'etat - switch(etat) - { - case 0: - led=1; break; - case 1: - led=1; break; - case 2: - led=0; break; - case 3: - led=0; break; - } - - wait_ms(10); - } -} -#endif
diff -r 69101b9b0c17 -r e906470d40b9 Exo3.cpp --- a/Exo3.cpp Wed Nov 10 16:51:26 2021 +0000 +++ b/Exo3.cpp Wed Nov 10 16:55:03 2021 +0000 @@ -27,19 +27,27 @@ switch(etat) { case 0 : if (bp==1) + { etat=1; + } break; case 1 : if (bp==0) + { etat=2; + } break; case 2 : if (bp==1) + { etat=3; + } break; case 3 : if (bp==0) + { etat=0; + } break; } //gestion des sorties