![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
oki
Fork of ProjetInfo2_Multi by
main.cpp
- Committer:
- thomasstrcic
- Date:
- 2018-06-01
- Revision:
- 2:ae058dfdebac
- Parent:
- 1:d446f0124474
- Child:
- 3:98f5de1dd010
- Child:
- 4:23e955d622f9
File content as of revision 2:ae058dfdebac:
#include "mbed.h" #include "coffre.h" #include "music.h" #define O 0.0193 #define F 0.0179 // VARIABLE ***************** extern BusIn digicode; DigitalOut led1(p20); DigitalOut led2(p18); Timer t1; Timer t2; Timer t3; int code[4]={2,1,0,3}; int etat =0; int N_precedent; int N; int juste; int count; Serial pc (USBTX,USBRX); // CODE ************ int main() { while(1) { N_precedent=N; t3.start(); if(t3.read()>0.01) { N=lireval(); t3.reset(); t3.stop(); } switch(etat) { case 0: if (count>=3) { led2.write(1); music(); //wait(3); 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(); } 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()>2) { etat=0; } break; case 5: if (t1.read()>1) { count++; pc.printf(" count = %d \n\r",count); pc.printf("c faux msieur\n\r"); etat=0; } pc.printf("etat =5\n\r"); break; } switch(etat) { case 0: //led1.write(1); led2.write(0); break; case 1: led1.write(0); led2.write(0); break; case 2: led1.write(0); led2.write(0); break; case 3: break; case 4: led1.write(0); //led2.write(1); servo(); break; } } }