oki

Dependencies:   mbed

Fork of ProjetInfo2_Multi by julien bitoun

Committer:
thomasstrcic
Date:
Fri Jun 01 11:36:44 2018 +0000
Revision:
2:ae058dfdebac
Parent:
1:d446f0124474
Child:
3:98f5de1dd010
Child:
4:23e955d622f9
suceez moi; ; ; ; ; ; ; ; ; ; ; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jujuonthebeat 0:5755bf39c144 1 #include "mbed.h"
jujuonthebeat 0:5755bf39c144 2 #include "coffre.h"
thomasstrcic 1:d446f0124474 3 #include "music.h"
jujuonthebeat 0:5755bf39c144 4
jujuonthebeat 0:5755bf39c144 5
thomasstrcic 1:d446f0124474 6 #define O 0.0193
thomasstrcic 2:ae058dfdebac 7 #define F 0.0179
thomasstrcic 1:d446f0124474 8
jujuonthebeat 0:5755bf39c144 9
jujuonthebeat 0:5755bf39c144 10
jujuonthebeat 0:5755bf39c144 11 // VARIABLE *****************
jujuonthebeat 0:5755bf39c144 12
thomasstrcic 2:ae058dfdebac 13
jujuonthebeat 0:5755bf39c144 14 extern BusIn digicode;
thomasstrcic 2:ae058dfdebac 15 DigitalOut led1(p20);
jujuonthebeat 0:5755bf39c144 16 DigitalOut led2(p18);
jujuonthebeat 0:5755bf39c144 17 Timer t1;
jujuonthebeat 0:5755bf39c144 18 Timer t2;
jujuonthebeat 0:5755bf39c144 19 Timer t3;
jujuonthebeat 0:5755bf39c144 20 int code[4]={2,1,0,3};
jujuonthebeat 0:5755bf39c144 21 int etat =0;
jujuonthebeat 0:5755bf39c144 22 int N_precedent;
thomasstrcic 1:d446f0124474 23 int N;
thomasstrcic 1:d446f0124474 24 int juste;
thomasstrcic 1:d446f0124474 25 int count;
jujuonthebeat 0:5755bf39c144 26 Serial pc (USBTX,USBRX);
jujuonthebeat 0:5755bf39c144 27
jujuonthebeat 0:5755bf39c144 28
jujuonthebeat 0:5755bf39c144 29
jujuonthebeat 0:5755bf39c144 30
jujuonthebeat 0:5755bf39c144 31 // CODE ************
jujuonthebeat 0:5755bf39c144 32
jujuonthebeat 0:5755bf39c144 33
jujuonthebeat 0:5755bf39c144 34 int main()
jujuonthebeat 0:5755bf39c144 35 {
thomasstrcic 2:ae058dfdebac 36
jujuonthebeat 0:5755bf39c144 37 while(1)
jujuonthebeat 0:5755bf39c144 38 {
jujuonthebeat 0:5755bf39c144 39 N_precedent=N;
jujuonthebeat 0:5755bf39c144 40 t3.start();
thomasstrcic 2:ae058dfdebac 41 if(t3.read()>0.01)
jujuonthebeat 0:5755bf39c144 42 {
jujuonthebeat 0:5755bf39c144 43 N=lireval();
jujuonthebeat 0:5755bf39c144 44 t3.reset();
jujuonthebeat 0:5755bf39c144 45 t3.stop();
jujuonthebeat 0:5755bf39c144 46 }
jujuonthebeat 0:5755bf39c144 47
jujuonthebeat 0:5755bf39c144 48 switch(etat)
jujuonthebeat 0:5755bf39c144 49 {
jujuonthebeat 0:5755bf39c144 50 case 0:
thomasstrcic 1:d446f0124474 51 if (count>=3)
thomasstrcic 1:d446f0124474 52 {
thomasstrcic 1:d446f0124474 53
thomasstrcic 1:d446f0124474 54 led2.write(1);
thomasstrcic 1:d446f0124474 55 music();
thomasstrcic 2:ae058dfdebac 56 //wait(3);
thomasstrcic 1:d446f0124474 57 count=0;
thomasstrcic 1:d446f0124474 58 }
jujuonthebeat 0:5755bf39c144 59
jujuonthebeat 0:5755bf39c144 60 if ( N_precedent==-3 and N == code[0] )
jujuonthebeat 0:5755bf39c144 61 {
jujuonthebeat 0:5755bf39c144 62 etat=1;
jujuonthebeat 0:5755bf39c144 63 pc.printf("ok1\n\r");
jujuonthebeat 0:5755bf39c144 64 }
jujuonthebeat 0:5755bf39c144 65 if(N_precedent == -3 and N!=code[0] and N!=-3)
jujuonthebeat 0:5755bf39c144 66 {
jujuonthebeat 0:5755bf39c144 67 etat=5;
jujuonthebeat 0:5755bf39c144 68 t1.reset();
jujuonthebeat 0:5755bf39c144 69 t1.start();
jujuonthebeat 0:5755bf39c144 70
jujuonthebeat 0:5755bf39c144 71 }
thomasstrcic 2:ae058dfdebac 72 pc.printf("etat =0\n\r");
jujuonthebeat 0:5755bf39c144 73 break;
jujuonthebeat 0:5755bf39c144 74 case 1 :
jujuonthebeat 0:5755bf39c144 75
thomasstrcic 2:ae058dfdebac 76 pc.printf("etat =1\n\r");
jujuonthebeat 0:5755bf39c144 77 if ( N_precedent==-3 and N == code[1])
jujuonthebeat 0:5755bf39c144 78 {
jujuonthebeat 0:5755bf39c144 79 etat=2;
jujuonthebeat 0:5755bf39c144 80 pc.printf("ok2\n\r");
jujuonthebeat 0:5755bf39c144 81 }
jujuonthebeat 0:5755bf39c144 82
jujuonthebeat 0:5755bf39c144 83 if(N_precedent == -3 and N!=code[1] and N!=-3)
jujuonthebeat 0:5755bf39c144 84 {
jujuonthebeat 0:5755bf39c144 85 etat=5;
jujuonthebeat 0:5755bf39c144 86 t1.reset();
jujuonthebeat 0:5755bf39c144 87 t1.start();
jujuonthebeat 0:5755bf39c144 88 }
jujuonthebeat 0:5755bf39c144 89 break;
jujuonthebeat 0:5755bf39c144 90 case 2 :
thomasstrcic 2:ae058dfdebac 91 pc.printf("etat =2\n\r");
jujuonthebeat 0:5755bf39c144 92 if( N_precedent==-3 and N == code[2])
jujuonthebeat 0:5755bf39c144 93 {
jujuonthebeat 0:5755bf39c144 94 etat=3;
jujuonthebeat 0:5755bf39c144 95 pc.printf("ok3\n\r");
jujuonthebeat 0:5755bf39c144 96 }
jujuonthebeat 0:5755bf39c144 97 if(N_precedent == -3 and N!=code[2] and N!=-3)
jujuonthebeat 0:5755bf39c144 98 {
jujuonthebeat 0:5755bf39c144 99 etat=5;
jujuonthebeat 0:5755bf39c144 100 t1.reset();
jujuonthebeat 0:5755bf39c144 101 t1.start();
jujuonthebeat 0:5755bf39c144 102 }
jujuonthebeat 0:5755bf39c144 103 break;
jujuonthebeat 0:5755bf39c144 104 case 3 :
thomasstrcic 2:ae058dfdebac 105 pc.printf("etat =3\n\r");
jujuonthebeat 0:5755bf39c144 106 if ( N_precedent==-3 and N == code[3])
jujuonthebeat 0:5755bf39c144 107 {
jujuonthebeat 0:5755bf39c144 108 etat=4;
jujuonthebeat 0:5755bf39c144 109 pc.printf("bravo c bon msieur\n\r");
thomasstrcic 1:d446f0124474 110 juste=1;
thomasstrcic 2:ae058dfdebac 111
thomasstrcic 2:ae058dfdebac 112 //wait(0.5);
jujuonthebeat 0:5755bf39c144 113 t2.reset();
jujuonthebeat 0:5755bf39c144 114 t2.start();
jujuonthebeat 0:5755bf39c144 115 }
jujuonthebeat 0:5755bf39c144 116 if(N_precedent == -3 and N!=code[3] and N!=-3)
jujuonthebeat 0:5755bf39c144 117 {
jujuonthebeat 0:5755bf39c144 118 etat=5;
jujuonthebeat 0:5755bf39c144 119 t1.reset();
jujuonthebeat 0:5755bf39c144 120 t1.start();
jujuonthebeat 0:5755bf39c144 121 }
jujuonthebeat 0:5755bf39c144 122 break;
jujuonthebeat 0:5755bf39c144 123
jujuonthebeat 0:5755bf39c144 124 case 4:
jujuonthebeat 0:5755bf39c144 125
jujuonthebeat 0:5755bf39c144 126
thomasstrcic 2:ae058dfdebac 127 pc.printf("etat =4\n\r");
thomasstrcic 1:d446f0124474 128 if(t2.read()>2)
jujuonthebeat 0:5755bf39c144 129 {
jujuonthebeat 0:5755bf39c144 130 etat=0;
jujuonthebeat 0:5755bf39c144 131 }
jujuonthebeat 0:5755bf39c144 132 break;
jujuonthebeat 0:5755bf39c144 133 case 5:
jujuonthebeat 0:5755bf39c144 134 if (t1.read()>1)
jujuonthebeat 0:5755bf39c144 135 {
thomasstrcic 1:d446f0124474 136 count++;
thomasstrcic 1:d446f0124474 137 pc.printf(" count = %d \n\r",count);
jujuonthebeat 0:5755bf39c144 138 pc.printf("c faux msieur\n\r");
jujuonthebeat 0:5755bf39c144 139 etat=0;
thomasstrcic 1:d446f0124474 140
jujuonthebeat 0:5755bf39c144 141 }
thomasstrcic 2:ae058dfdebac 142 pc.printf("etat =5\n\r");
thomasstrcic 1:d446f0124474 143
jujuonthebeat 0:5755bf39c144 144 break;
jujuonthebeat 0:5755bf39c144 145
jujuonthebeat 0:5755bf39c144 146 }
jujuonthebeat 0:5755bf39c144 147 switch(etat)
jujuonthebeat 0:5755bf39c144 148 {
jujuonthebeat 0:5755bf39c144 149 case 0:
thomasstrcic 1:d446f0124474 150 //led1.write(1);
jujuonthebeat 0:5755bf39c144 151 led2.write(0);
jujuonthebeat 0:5755bf39c144 152 break;
jujuonthebeat 0:5755bf39c144 153
jujuonthebeat 0:5755bf39c144 154 case 1:
jujuonthebeat 0:5755bf39c144 155 led1.write(0);
jujuonthebeat 0:5755bf39c144 156 led2.write(0);
jujuonthebeat 0:5755bf39c144 157 break;
jujuonthebeat 0:5755bf39c144 158
jujuonthebeat 0:5755bf39c144 159 case 2:
jujuonthebeat 0:5755bf39c144 160 led1.write(0);
jujuonthebeat 0:5755bf39c144 161 led2.write(0);
jujuonthebeat 0:5755bf39c144 162 break;
jujuonthebeat 0:5755bf39c144 163 case 3:
jujuonthebeat 0:5755bf39c144 164 break;
jujuonthebeat 0:5755bf39c144 165 case 4:
jujuonthebeat 0:5755bf39c144 166 led1.write(0);
thomasstrcic 1:d446f0124474 167 //led2.write(1);
thomasstrcic 2:ae058dfdebac 168 servo();
jujuonthebeat 0:5755bf39c144 169 break;
jujuonthebeat 0:5755bf39c144 170 }
jujuonthebeat 0:5755bf39c144 171
jujuonthebeat 0:5755bf39c144 172
jujuonthebeat 0:5755bf39c144 173 }
jujuonthebeat 0:5755bf39c144 174 }