![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Bonjour, ce code est pour Nathan Juranville , désolé pour le mail
Revision 0:6e18e2969238, committed 2019-11-20
- Comitter:
- Nthnthj
- Date:
- Wed Nov 20 14:02:40 2019 +0000
- Commit message:
- Bon chance 2 !
Changed in this revision
main_2_1.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 6e18e2969238 main_2_1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main_2_1.cpp Wed Nov 20 14:02:40 2019 +0000 @@ -0,0 +1,181 @@ +#include "mbed.h" + +InterruptIn my_button(USER_BUTTON); +//PwmOut my_pwm(D3); +DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); // tx, rx terminal +Timer timer; +Timer timer2; +InterruptIn event(A0); +InterruptIn event2(A1); +//DigitalOut laser(D3); + +bool flag= false; +bool flag2= false; +bool duo = false ; +bool pass1= false; +bool pass2= false; +float begin, end; +float debut2, fin1, fin2; + +void skater_d() +{ + + if(duo == false) { + printf("Ligne de depart coupee solo \n"); + if( flag == false && flag2 == false ) { + printf("Depart skate \n"); + begin = timer.read_ms(); + pc.printf(" skater lance %.0f \n", begin); + flag = true; + flag2= false; + } else if(flag == true && flag2 == true) { + printf("erreur \n"); + //end = timer.read_ms(); + //pc.printf(" skater arrive %.0f \n", end); + pc.printf(" Temps du skater : %.0f \n", end-begin); + flag = false; + } + + } + + else if(duo == true) { + printf("Ligne de depart coupee duo \n"); + if(pass1 == false) { + printf("arrive skate 1 duo \n"); + fin1 = timer2.read_ms(); + //pc.printf(" skater lance %.0f \n", begin); + pass1 = true; + } else if(pass1 == true) { + printf("ligne 1 deja coupee duo \n"); + //end = timer.read_ms(); + //pc.printf(" skater arrive %.0f \n", end); + //pc.printf(" Temps du skater : %.0f \n", end-begin); + //flag = false; + } + + + + } + if(pass1 == true && pass2== true ) { + printf("resultats : skater1 = %.0f , skater2 = %.0f . \n", fin1-debut2, fin2-debut2); + pass1 =false; + pass2 =false; + debut2= timer2.read_ms(); + } + + + +} + + +void skater_f() +{ + if(duo == false) { + + printf("Ligne d'arrivee coupee \n"); + if( flag == false && flag2 == true) { + printf("arrivee coupe sans depart\n"); + //begin = timer.read_ms(); + //pc.printf(" skater arret a %.0f \n", begin); + flag = true; + } else if(flag == true && flag2 ==false ) { + printf("Arrivee skate \n"); + end = timer.read_ms(); + //pc.printf(" skater arrive %.0f \n", end); + pc.printf(" Temps du skater : %.0f \n", end-begin); + flag = false; + flag2=false; + } + + } else if(duo == true) { + printf("Ligne 2 de depart coupee duo \n"); + if(pass2 == false) { + printf("arrive skate 2 duo \n"); + fin2 = timer2.read_ms(); + //pc.printf(" skater lance %.0f \n", begin); + pass2 = true; + + + } else if(pass2 == true) { + printf("ligne 2 deja coupee duo \n"); + //end = timer.read_ms(); + //pc.printf(" skater arrive %.0f \n", end); + //pc.printf(" Temps du skater : %.0f \n", end-begin); + //flag = false; + } + + //printf("resultats : skater1 = %.0f , skater2 = %.0f . \n", fin1-debut2, fin2-debut2); + + } + if(pass1 == true && pass2== true ) { + printf("resultats : skater1 = %.0f , skater2 = %.0f . \n", fin1-debut2, fin2-debut2); + pass1 =false; + pass2 =false; + debut2= timer2.read_ms(); + } +} + +void pressed() { + /* + if(duo == false){ + //pc.printf("rapport cyclique : 0.5 "); + // pc.scanf("%f", &valeur_pwm); + //my_pwm.write(0.5); + //my_pwm.period_ms(500); + pc.printf("choix de course : solo \n"); + //laser=1; + wait(0.05); + } + else if (duo == true){ + //pc.printf("rapport cyclique : 0 "); + // pc.scanf("%f", &valeur_pwm); + //my_pwm.write(0); + //my_pwm.period_ms(500); + pc.printf("choix de course : duo \n"); + //laser=0; + wait(0.05); + timer2.start(); + debut2= timer2.read_ms(); + } + //test=my_pwm.read(); + //pc.printf("%f", test); + */ + duo = !duo ; + +} + + +/* +void choix() { + char cValue; + pc.printf("Press '1' to go solo, '0' to go duo \n"); + + char c = pc.scanf("%c", &cValue); // Read hyperterminal + if (c == '0') { + duo = true; // OFF + pc.printf("choix de course : duo \n"); + } + if (c == '1') { + duo = false; // ON + pc.printf("choix de course : solo \n"); + } + } + +*/ + +int main() +{ + + //duo=false; + + my_button.fall(&pressed); + timer.start(); + timer2.start(); + event.fall(&skater_d); + event2.fall(skater_f); + + + while(1) { + } +} \ No newline at end of file
diff -r 000000000000 -r 6e18e2969238 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 20 14:02:40 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file