thomas strcic
/
ProjetInfo2_Multi12
oki
Fork of ProjetInfo2_Multi by
Diff: main.cpp
- Revision:
- 3:98f5de1dd010
- Parent:
- 2:ae058dfdebac
--- a/main.cpp Fri Jun 01 11:36:44 2018 +0000 +++ b/main.cpp Tue Jun 05 11:54:56 2018 +0000 @@ -16,14 +16,18 @@ DigitalOut led2(p18); Timer t1; Timer t2; -Timer t3; -int code[4]={2,1,0,3}; -int etat =0; -int N_precedent; -int N; +extern int u; +extern Timer t3; +extern int code[4]; +extern int etat =0; +extern int N_precedent; +extern int N; int juste; int count; -Serial pc (USBTX,USBRX); + extern Serial pc; + Serial bluetooth(p28,p27); + char chara; + int val; @@ -40,11 +44,18 @@ t3.start(); if(t3.read()>0.01) { - N=lireval(); + if (bluetooth.readable()) + { + chara=bluetooth.getc(); + N=chara-'0'; + } + + t3.reset(); t3.stop(); } - + pc.printf("%d \n\r",N_precedent); + pc.printf("%d \n\r",N); switch(etat) { case 0: @@ -53,34 +64,39 @@ led2.write(1); music(); - //wait(3); + wait(3); count=0; } - if ( N_precedent==-3 and N == code[0] ) + if ( N_precedent==0 and N == code[0] ) { etat=1; pc.printf("ok1\n\r"); } - if(N_precedent == -3 and N!=code[0] and N!=-3) + if(N_precedent == 0 and N!=code[0] and N!=0) { etat=5; t1.reset(); t1.start(); } + if (N_precedent==0 and N==10) + { + changement_code(code); + u=0; + } pc.printf("etat =0\n\r"); break; case 1 : pc.printf("etat =1\n\r"); - if ( N_precedent==-3 and N == code[1]) + if ( N_precedent==code[0] and N == code[1]) { etat=2; pc.printf("ok2\n\r"); } - if(N_precedent == -3 and N!=code[1] and N!=-3) + if(N_precedent == code[0] and N!=code[1] and N!=-3) { etat=5; t1.reset(); @@ -109,7 +125,7 @@ pc.printf("bravo c bon msieur\n\r"); juste=1; - //wait(0.5); + wait(0.5); t2.reset(); t2.start(); } @@ -125,7 +141,7 @@ pc.printf("etat =4\n\r"); - if(t2.read()>2) + if(t2.read()>0.5) { etat=0; }