![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
oki
Fork of ProjetInfo2_Multi by
main.cpp
- Committer:
- thomasstrcic
- Date:
- 2018-06-12
- Revision:
- 4:23e955d622f9
- Parent:
- 2:ae058dfdebac
File content as of revision 4:23e955d622f9:
#include "mbed.h" #include "coffre.h" #include "music.h" #include "TextLCD.h" #define O 0.0193 #define F 0.0179 // VARIABLE ***************** extern TextLCD LCD ; extern BusIn digicode; DigitalOut led1(p20); DigitalOut led2(p18); Timer t1; Timer t2; 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; extern Serial pc; extern Serial bluetooth; extern char chara; DigitalIn bp (p30); // CODE ************ int main() { bp.mode(PullUp); while(1) { N_precedent=N; t3.start(); if (bluetooth.readable()) { chara=bluetooth.getc(); N=chara-'0'; } else { N=-3; } if (N==10) { N=-2; } switch(etat) { case 0: LCD.cls(); LCD.printf("code :"); if (count>=3) { led2.write(1); LCD.cls(); LCD.printf("appel"); LCD.locate(0,1); LCD.printf("police"); music(); wait(3); LCD.cls(); count=0; } if ( N_precedent==-3 and N == code[0] ) { etat=1; pc.printf("ok1\n\r"); } if(N_precedent == -3 and N!=code[0] and N!=-3) { etat=5; t1.reset(); t1.start(); } if (N_precedent==-3 and bp.read()==0) { 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]) { etat=2; pc.printf("ok2\n\r"); } if(N_precedent == -3 and N!=code[1] and N!=-3) { etat=5; t1.reset(); t1.start(); } break; case 2 : pc.printf("etat =2\n\r"); if( N_precedent==-3 and N == code[2]) { etat=3; pc.printf("ok3\n\r"); } if(N_precedent == -3 and N!=code[2] and N!=-3) { etat=5; t1.reset(); t1.start(); } break; case 3 : pc.printf("etat =3\n\r"); if ( N_precedent==-3 and N == code[3]) { etat=4; pc.printf("bravo c bon msieur\n\r"); juste=1; wait(0.5); t2.reset(); t2.start(); } if(N_precedent == -3 and N!=code[3] and N!=-3) { etat=5; t1.reset(); t1.start(); } break; case 4: pc.printf("etat =4\n\r"); if(t2.read()>0.5) { etat=0; } break; case 5: if (t1.read()>1) { count++; pc.printf(" count = %d \n\r",count); pc.printf("c faux msieur\n\r"); LCD.cls(); LCD.printf("code faux"); //music(); etat=0; } pc.printf("etat =5\n\r"); break; } switch(etat) { case 0: break; case 1: LCD.locate(0,1); LCD.printf("*"); break; case 2: LCD.locate(1,1); LCD.printf("*"); break; case 3: LCD.locate(2,1); LCD.printf("*"); break; case 4: LCD.cls(); LCD.printf("code"); LCD.locate(0,1); LCD.printf("BON"); servo(); //wait(1); LCD.cls(); break; case 5: LCD.cls(); LCD.printf("code"); LCD.locate(0,1); LCD.printf("faux"); break; } } }