programme bts bruchet descroix duhautois
Dependencies: mbed ID12RFID SDFileSystem
main.cpp@7:5132b1d68c11, 2021-05-10 (annotated)
- Committer:
- valentinbruchet
- Date:
- Mon May 10 16:46:51 2021 +0000
- Revision:
- 7:5132b1d68c11
- Parent:
- 6:4f5634f6a565
programme;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
valentinbruchet | 5:e104ec24b3fa | 1 | #include "mbed.h" |
valentinbruchet | 5:e104ec24b3fa | 2 | #include "mbed_genie.h" |
valentinbruchet | 5:e104ec24b3fa | 3 | #include "eeprom_flash.h" |
valentinbruchet | 5:e104ec24b3fa | 4 | #include "SDFileSystem.h" |
valentinbruchet | 5:e104ec24b3fa | 5 | #include "ID12RFID.h" |
valentinbruchet | 5:e104ec24b3fa | 6 | |
valentinbruchet | 5:e104ec24b3fa | 7 | Serial pc(USBTX, USBRX); |
valentinbruchet | 5:e104ec24b3fa | 8 | ID12RFID rfid(PA_10); |
valentinbruchet | 5:e104ec24b3fa | 9 | |
valentinbruchet | 7:5132b1d68c11 | 10 | //DigitalOut myled(LED1); |
valentinbruchet | 5:e104ec24b3fa | 11 | DigitalOut led1(PA_8); |
valentinbruchet | 5:e104ec24b3fa | 12 | DigitalOut led2(PB_14); |
valentinbruchet | 5:e104ec24b3fa | 13 | DigitalOut led3(PB_11); |
valentinbruchet | 5:e104ec24b3fa | 14 | DigitalOut led4(PA_11); |
valentinbruchet | 5:e104ec24b3fa | 15 | DigitalOut led5(PA_12); |
valentinbruchet | 5:e104ec24b3fa | 16 | DigitalOut led6(PC_5); |
valentinbruchet | 5:e104ec24b3fa | 17 | DigitalOut led7(PC_6); |
valentinbruchet | 5:e104ec24b3fa | 18 | DigitalOut led8(PC_8); |
valentinbruchet | 5:e104ec24b3fa | 19 | DigitalOut ledmasse(PB_3); |
valentinbruchet | 5:e104ec24b3fa | 20 | |
valentinbruchet | 5:e104ec24b3fa | 21 | int flag_contraste; |
valentinbruchet | 5:e104ec24b3fa | 22 | int valeur_clavier; |
valentinbruchet | 5:e104ec24b3fa | 23 | int i; |
valentinbruchet | 5:e104ec24b3fa | 24 | unsigned int lecture; |
valentinbruchet | 5:e104ec24b3fa | 25 | int code1 = 49; |
valentinbruchet | 5:e104ec24b3fa | 26 | int code2 = 50; |
valentinbruchet | 5:e104ec24b3fa | 27 | int code3 = 51; |
valentinbruchet | 5:e104ec24b3fa | 28 | int y = 15; |
valentinbruchet | 5:e104ec24b3fa | 29 | int flag = 0; |
valentinbruchet | 5:e104ec24b3fa | 30 | int adressetempo = 0x0000; |
valentinbruchet | 5:e104ec24b3fa | 31 | int adresserfid = 0x00000000; |
valentinbruchet | 5:e104ec24b3fa | 32 | unsigned int tempo1, tempo2, tempo3, tempo4, tempo5, tempo6, tempo7,tempo8, rfid1, rfid2, rfid3, rfid4, rfid5; |
valentinbruchet | 5:e104ec24b3fa | 33 | |
valentinbruchet | 5:e104ec24b3fa | 34 | |
valentinbruchet | 5:e104ec24b3fa | 35 | void enableEEPROMWriting() |
valentinbruchet | 5:e104ec24b3fa | 36 | { |
valentinbruchet | 5:e104ec24b3fa | 37 | HAL_StatusTypeDef status = HAL_FLASH_Unlock(); |
valentinbruchet | 5:e104ec24b3fa | 38 | FLASH_PageErase(EEPROM_START_ADDRESS); // required to re-write |
valentinbruchet | 5:e104ec24b3fa | 39 | CLEAR_BIT(FLASH->CR, FLASH_CR_PER); // Bug fix: bit PER has been set in Flash_PageErase(), must clear it here |
valentinbruchet | 5:e104ec24b3fa | 40 | } |
valentinbruchet | 5:e104ec24b3fa | 41 | |
valentinbruchet | 5:e104ec24b3fa | 42 | void disableEEPROMWriting() |
valentinbruchet | 5:e104ec24b3fa | 43 | { |
valentinbruchet | 5:e104ec24b3fa | 44 | HAL_FLASH_Lock(); |
valentinbruchet | 5:e104ec24b3fa | 45 | } |
valentinbruchet | 5:e104ec24b3fa | 46 | |
valentinbruchet | 5:e104ec24b3fa | 47 | HAL_StatusTypeDef writeEEPROMWord(uint32_t address, uint32_t data) |
valentinbruchet | 5:e104ec24b3fa | 48 | { |
valentinbruchet | 5:e104ec24b3fa | 49 | HAL_StatusTypeDef status; |
valentinbruchet | 5:e104ec24b3fa | 50 | address = address + EEPROM_START_ADDRESS; |
valentinbruchet | 5:e104ec24b3fa | 51 | status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data); |
valentinbruchet | 5:e104ec24b3fa | 52 | return status; |
valentinbruchet | 5:e104ec24b3fa | 53 | } |
valentinbruchet | 5:e104ec24b3fa | 54 | |
valentinbruchet | 5:e104ec24b3fa | 55 | uint32_t readEEPROMWord(uint32_t address) |
valentinbruchet | 5:e104ec24b3fa | 56 | { |
valentinbruchet | 5:e104ec24b3fa | 57 | uint32_t val = 0; |
valentinbruchet | 5:e104ec24b3fa | 58 | address = address + EEPROM_START_ADDRESS; |
valentinbruchet | 5:e104ec24b3fa | 59 | val = *(__IO uint32_t*)address; |
valentinbruchet | 5:e104ec24b3fa | 60 | return val; |
valentinbruchet | 5:e104ec24b3fa | 61 | } |
valentinbruchet | 5:e104ec24b3fa | 62 | |
valentinbruchet | 5:e104ec24b3fa | 63 | void myGenieEventHandler(void) |
valentinbruchet | 5:e104ec24b3fa | 64 | { |
valentinbruchet | 5:e104ec24b3fa | 65 | genieFrame Event; |
valentinbruchet | 5:e104ec24b3fa | 66 | genieDequeueEvent(&Event); |
valentinbruchet | 5:e104ec24b3fa | 67 | if(Event.reportObject.cmd == GENIE_REPORT_EVENT) |
valentinbruchet | 5:e104ec24b3fa | 68 | { |
valentinbruchet | 5:e104ec24b3fa | 69 | if (Event.reportObject.object == GENIE_OBJ_KEYBOARD) |
valentinbruchet | 5:e104ec24b3fa | 70 | { |
valentinbruchet | 5:e104ec24b3fa | 71 | if (Event.reportObject.index == 0) |
valentinbruchet | 5:e104ec24b3fa | 72 | { |
valentinbruchet | 5:e104ec24b3fa | 73 | valeur_clavier = Event.reportObject.data_lsb; |
valentinbruchet | 5:e104ec24b3fa | 74 | printf("%c\n\r", valeur_clavier); |
valentinbruchet | 5:e104ec24b3fa | 75 | if ((valeur_clavier == code1) || (valeur_clavier== code2) || (valeur_clavier == code3)) |
valentinbruchet | 5:e104ec24b3fa | 76 | { |
valentinbruchet | 5:e104ec24b3fa | 77 | printf("Acces autorise\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 78 | } |
valentinbruchet | 5:e104ec24b3fa | 79 | else |
valentinbruchet | 5:e104ec24b3fa | 80 | { |
valentinbruchet | 5:e104ec24b3fa | 81 | printf("Acces refuse\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 82 | } |
valentinbruchet | 5:e104ec24b3fa | 83 | } |
valentinbruchet | 5:e104ec24b3fa | 84 | } |
valentinbruchet | 5:e104ec24b3fa | 85 | if (Event.reportObject.object == GENIE_OBJ_4DBUTTON) |
valentinbruchet | 5:e104ec24b3fa | 86 | { |
valentinbruchet | 5:e104ec24b3fa | 87 | if (Event.reportObject.index == 3) //Start |
valentinbruchet | 5:e104ec24b3fa | 88 | { |
valentinbruchet | 5:e104ec24b3fa | 89 | printf("Depart\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 90 | flag=1; |
valentinbruchet | 5:e104ec24b3fa | 91 | } |
valentinbruchet | 5:e104ec24b3fa | 92 | if (Event.reportObject.index == 5) //Stop |
valentinbruchet | 5:e104ec24b3fa | 93 | { |
valentinbruchet | 5:e104ec24b3fa | 94 | printf("Stop\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 95 | flag=0; |
valentinbruchet | 5:e104ec24b3fa | 96 | } |
valentinbruchet | 5:e104ec24b3fa | 97 | /*if (Event.reportObject.index == 8) // Contraste + |
valentinbruchet | 5:e104ec24b3fa | 98 | { |
valentinbruchet | 5:e104ec24b3fa | 99 | if (y<15) |
valentinbruchet | 5:e104ec24b3fa | 100 | { |
valentinbruchet | 5:e104ec24b3fa | 101 | y++; |
valentinbruchet | 5:e104ec24b3fa | 102 | printf("Contraste=%d\r\n",y); |
valentinbruchet | 5:e104ec24b3fa | 103 | flag_contraste=1; |
valentinbruchet | 5:e104ec24b3fa | 104 | } |
valentinbruchet | 5:e104ec24b3fa | 105 | genieWriteContrast(y); |
valentinbruchet | 5:e104ec24b3fa | 106 | } |
valentinbruchet | 5:e104ec24b3fa | 107 | if (Event.reportObject.index == 7) // Contraste - |
valentinbruchet | 5:e104ec24b3fa | 108 | { |
valentinbruchet | 5:e104ec24b3fa | 109 | if (y>0) |
valentinbruchet | 5:e104ec24b3fa | 110 | { |
valentinbruchet | 5:e104ec24b3fa | 111 | y--; |
valentinbruchet | 5:e104ec24b3fa | 112 | printf("Contraste=%d\r\n",y); |
valentinbruchet | 5:e104ec24b3fa | 113 | flag_contraste=1; |
valentinbruchet | 5:e104ec24b3fa | 114 | } |
valentinbruchet | 5:e104ec24b3fa | 115 | genieWriteContrast(y); |
valentinbruchet | 5:e104ec24b3fa | 116 | }*/ |
valentinbruchet | 5:e104ec24b3fa | 117 | if (Event.reportObject.index == 6) //Lecture tempo |
valentinbruchet | 5:e104ec24b3fa | 118 | { |
valentinbruchet | 5:e104ec24b3fa | 119 | SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd"); |
valentinbruchet | 5:e104ec24b3fa | 120 | char numberstring[100]; |
valentinbruchet | 5:e104ec24b3fa | 121 | FILE *fp = fopen("/sd/valeur_temporisation.txt", "r"); |
valentinbruchet | 5:e104ec24b3fa | 122 | fgets(numberstring, 100, fp); |
valentinbruchet | 5:e104ec24b3fa | 123 | |
valentinbruchet | 5:e104ec24b3fa | 124 | if(fp == NULL) |
valentinbruchet | 5:e104ec24b3fa | 125 | { |
valentinbruchet | 5:e104ec24b3fa | 126 | error("Impossible d'ouvrir le fichier pour la lecture\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 127 | fclose(fp); |
valentinbruchet | 5:e104ec24b3fa | 128 | } |
valentinbruchet | 5:e104ec24b3fa | 129 | else |
valentinbruchet | 5:e104ec24b3fa | 130 | { |
valentinbruchet | 5:e104ec24b3fa | 131 | printf("Lecture temporisation\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 132 | enableEEPROMWriting(); |
valentinbruchet | 5:e104ec24b3fa | 133 | sscanf(numberstring, "%d", &tempo1); |
valentinbruchet | 5:e104ec24b3fa | 134 | writeEEPROMWord(adressetempo, tempo1); |
valentinbruchet | 5:e104ec24b3fa | 135 | lecture=readEEPROMWord(adressetempo); |
valentinbruchet | 5:e104ec24b3fa | 136 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 137 | printf ("carte : %d\n\r",tempo1); |
valentinbruchet | 5:e104ec24b3fa | 138 | sscanf(numberstring+3, "%d", &tempo2); |
valentinbruchet | 5:e104ec24b3fa | 139 | writeEEPROMWord(adressetempo+4, tempo2); |
valentinbruchet | 5:e104ec24b3fa | 140 | lecture=readEEPROMWord(adressetempo+4); |
valentinbruchet | 5:e104ec24b3fa | 141 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 142 | printf ("carte : %d\n\r",tempo2); |
valentinbruchet | 5:e104ec24b3fa | 143 | sscanf(numberstring+6, "%d", &tempo3); |
valentinbruchet | 5:e104ec24b3fa | 144 | writeEEPROMWord(adressetempo+8, tempo3); |
valentinbruchet | 5:e104ec24b3fa | 145 | lecture=readEEPROMWord(adressetempo+8); |
valentinbruchet | 5:e104ec24b3fa | 146 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 147 | printf ("carte : %d\n\r",tempo3); |
valentinbruchet | 5:e104ec24b3fa | 148 | sscanf(numberstring+9, "%d", &tempo4); |
valentinbruchet | 5:e104ec24b3fa | 149 | writeEEPROMWord(adressetempo+12, tempo4); |
valentinbruchet | 5:e104ec24b3fa | 150 | lecture=readEEPROMWord(adressetempo+12); |
valentinbruchet | 5:e104ec24b3fa | 151 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 152 | printf ("carte : %d\n\r",tempo4); |
valentinbruchet | 5:e104ec24b3fa | 153 | sscanf(numberstring+11, "%d", &tempo5); |
valentinbruchet | 5:e104ec24b3fa | 154 | writeEEPROMWord(adressetempo+16, tempo5); |
valentinbruchet | 5:e104ec24b3fa | 155 | lecture=readEEPROMWord(adressetempo+16); |
valentinbruchet | 5:e104ec24b3fa | 156 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 157 | printf ("carte : %d\n\r",tempo5); |
valentinbruchet | 5:e104ec24b3fa | 158 | sscanf(numberstring+14, "%d", &tempo6); |
valentinbruchet | 5:e104ec24b3fa | 159 | writeEEPROMWord(adressetempo+20, tempo6); |
valentinbruchet | 5:e104ec24b3fa | 160 | lecture=readEEPROMWord(adressetempo+20); |
valentinbruchet | 5:e104ec24b3fa | 161 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 162 | printf ("carte : %d\n\r",tempo6); |
valentinbruchet | 5:e104ec24b3fa | 163 | sscanf(numberstring+16, "%d", &tempo7); |
valentinbruchet | 5:e104ec24b3fa | 164 | writeEEPROMWord(adressetempo+24, tempo7); |
valentinbruchet | 5:e104ec24b3fa | 165 | lecture=readEEPROMWord(adressetempo+24); |
valentinbruchet | 5:e104ec24b3fa | 166 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 167 | printf ("carte : %d\n\r",tempo7); |
valentinbruchet | 5:e104ec24b3fa | 168 | sscanf(numberstring+18, "%d", &tempo8); |
valentinbruchet | 5:e104ec24b3fa | 169 | writeEEPROMWord(adressetempo+28, tempo8); |
valentinbruchet | 5:e104ec24b3fa | 170 | lecture=readEEPROMWord(adressetempo+28); |
valentinbruchet | 5:e104ec24b3fa | 171 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 172 | printf ("carte : %d\n\r",tempo8); |
valentinbruchet | 5:e104ec24b3fa | 173 | fclose(fp); |
valentinbruchet | 5:e104ec24b3fa | 174 | printf("Lecture finie!\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 175 | disableEEPROMWriting(); |
valentinbruchet | 5:e104ec24b3fa | 176 | } |
valentinbruchet | 5:e104ec24b3fa | 177 | } |
valentinbruchet | 5:e104ec24b3fa | 178 | if (Event.reportObject.index == 7) //Lecture code RFID |
valentinbruchet | 5:e104ec24b3fa | 179 | { |
valentinbruchet | 5:e104ec24b3fa | 180 | SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd"); |
valentinbruchet | 5:e104ec24b3fa | 181 | char numberrfid[100]; |
valentinbruchet | 5:e104ec24b3fa | 182 | FILE *fp1 = fopen("/sd/valeur_rfid.txt", "r"); |
valentinbruchet | 5:e104ec24b3fa | 183 | fgets(numberrfid, 100, fp1); |
valentinbruchet | 5:e104ec24b3fa | 184 | |
valentinbruchet | 5:e104ec24b3fa | 185 | if(fp1 == NULL) |
valentinbruchet | 5:e104ec24b3fa | 186 | { |
valentinbruchet | 5:e104ec24b3fa | 187 | error("Impossible d'ouvrir le fichier pour la lecture\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 188 | } |
valentinbruchet | 5:e104ec24b3fa | 189 | flag = 2; |
valentinbruchet | 5:e104ec24b3fa | 190 | printf("Lecture code rfid\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 191 | enableEEPROMWriting(); |
valentinbruchet | 5:e104ec24b3fa | 192 | sscanf(numberrfid, "%d", &rfid1); |
valentinbruchet | 5:e104ec24b3fa | 193 | writeEEPROMWord(adresserfid, rfid1); |
valentinbruchet | 5:e104ec24b3fa | 194 | lecture=readEEPROMWord(adresserfid); |
valentinbruchet | 5:e104ec24b3fa | 195 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 196 | printf ("carte : %d\n\r", rfid1); |
valentinbruchet | 5:e104ec24b3fa | 197 | sscanf(numberrfid+8, "%d", &rfid2); |
valentinbruchet | 5:e104ec24b3fa | 198 | writeEEPROMWord(adresserfid+8, rfid2); |
valentinbruchet | 5:e104ec24b3fa | 199 | lecture=readEEPROMWord(adresserfid+8); |
valentinbruchet | 5:e104ec24b3fa | 200 | printf ("eeprom: %d\n\r",lecture);; |
valentinbruchet | 5:e104ec24b3fa | 201 | printf ("carte : %d\n\r", rfid2); |
valentinbruchet | 5:e104ec24b3fa | 202 | sscanf(numberrfid+17, "%d", &rfid3); |
valentinbruchet | 5:e104ec24b3fa | 203 | writeEEPROMWord(adresserfid+16, rfid3); |
valentinbruchet | 5:e104ec24b3fa | 204 | lecture=readEEPROMWord(adresserfid+16); |
valentinbruchet | 5:e104ec24b3fa | 205 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 206 | printf ("carte : %d\n\r", rfid3); |
valentinbruchet | 5:e104ec24b3fa | 207 | sscanf(numberrfid+25, "%d", &rfid4); |
valentinbruchet | 5:e104ec24b3fa | 208 | writeEEPROMWord(adresserfid+24, rfid4); |
valentinbruchet | 5:e104ec24b3fa | 209 | lecture=readEEPROMWord(adresserfid+24); |
valentinbruchet | 5:e104ec24b3fa | 210 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 211 | printf ("carte : %d\n\r", rfid4); |
valentinbruchet | 5:e104ec24b3fa | 212 | sscanf(numberrfid+34, "%d", &rfid5); |
valentinbruchet | 5:e104ec24b3fa | 213 | writeEEPROMWord(adresserfid+32, rfid5); |
valentinbruchet | 5:e104ec24b3fa | 214 | lecture=readEEPROMWord(adresserfid+32); |
valentinbruchet | 5:e104ec24b3fa | 215 | printf ("eeprom: %d\n\r",lecture); |
valentinbruchet | 5:e104ec24b3fa | 216 | printf ("carte : %d\n\r", rfid5); |
valentinbruchet | 5:e104ec24b3fa | 217 | fclose(fp1); |
valentinbruchet | 5:e104ec24b3fa | 218 | printf("Lecture finie!\n\r"); |
valentinbruchet | 5:e104ec24b3fa | 219 | disableEEPROMWriting(); |
valentinbruchet | 5:e104ec24b3fa | 220 | } |
valentinbruchet | 5:e104ec24b3fa | 221 | } |
valentinbruchet | 5:e104ec24b3fa | 222 | } |
valentinbruchet | 5:e104ec24b3fa | 223 | return; |
valentinbruchet | 5:e104ec24b3fa | 224 | } |
valentinbruchet | 5:e104ec24b3fa | 225 | int main() |
valentinbruchet | 6:4f5634f6a565 | 226 | { |
valentinbruchet | 5:e104ec24b3fa | 227 | pc.baud(9600); |
valentinbruchet | 5:e104ec24b3fa | 228 | ledmasse = 1; |
valentinbruchet | 5:e104ec24b3fa | 229 | SetupGenie(); |
valentinbruchet | 5:e104ec24b3fa | 230 | genieAttachEventHandler(&myGenieEventHandler); |
valentinbruchet | 5:e104ec24b3fa | 231 | genieWriteContrast(15); |
valentinbruchet | 6:4f5634f6a565 | 232 | genieWriteObject(GENIE_OBJ_USER_LED, 0, 1); |
valentinbruchet | 5:e104ec24b3fa | 233 | |
valentinbruchet | 5:e104ec24b3fa | 234 | while(1) |
valentinbruchet | 5:e104ec24b3fa | 235 | { |
valentinbruchet | 5:e104ec24b3fa | 236 | if (flag == 1) |
valentinbruchet | 5:e104ec24b3fa | 237 | { |
valentinbruchet | 5:e104ec24b3fa | 238 | led1 = 1; |
valentinbruchet | 6:4f5634f6a565 | 239 | wait(tempo1); |
valentinbruchet | 6:4f5634f6a565 | 240 | led1 = 0; |
valentinbruchet | 5:e104ec24b3fa | 241 | led2 = 1; |
valentinbruchet | 6:4f5634f6a565 | 242 | wait(tempo2); |
valentinbruchet | 6:4f5634f6a565 | 243 | led2 = 0; |
valentinbruchet | 5:e104ec24b3fa | 244 | led3 = 1; |
valentinbruchet | 6:4f5634f6a565 | 245 | wait(tempo3); |
valentinbruchet | 6:4f5634f6a565 | 246 | led3 = 0; |
valentinbruchet | 5:e104ec24b3fa | 247 | led4 = 1; |
valentinbruchet | 6:4f5634f6a565 | 248 | wait(tempo4); |
valentinbruchet | 6:4f5634f6a565 | 249 | led4 = 0; |
valentinbruchet | 6:4f5634f6a565 | 250 | led5 = 1; |
valentinbruchet | 6:4f5634f6a565 | 251 | wait(tempo5); |
valentinbruchet | 5:e104ec24b3fa | 252 | led5 = 0; |
valentinbruchet | 6:4f5634f6a565 | 253 | led6 = 1; |
valentinbruchet | 6:4f5634f6a565 | 254 | wait(tempo6); |
valentinbruchet | 5:e104ec24b3fa | 255 | led6 = 0; |
valentinbruchet | 6:4f5634f6a565 | 256 | led7 = 1; |
valentinbruchet | 6:4f5634f6a565 | 257 | wait(tempo7); |
valentinbruchet | 5:e104ec24b3fa | 258 | led7 = 0; |
valentinbruchet | 6:4f5634f6a565 | 259 | led8 = 1; |
valentinbruchet | 6:4f5634f6a565 | 260 | wait(tempo8); |
valentinbruchet | 5:e104ec24b3fa | 261 | led8 = 0; |
valentinbruchet | 6:4f5634f6a565 | 262 | /*wait(1); |
valentinbruchet | 5:e104ec24b3fa | 263 | if (chrono == 0) |
valentinbruchet | 5:e104ec24b3fa | 264 | { |
valentinbruchet | 5:e104ec24b3fa | 265 | chrono=tab[i]; |
valentinbruchet | 5:e104ec24b3fa | 266 | i=i+1; |
valentinbruchet | 6:4f5634f6a565 | 267 | }*/ |
valentinbruchet | 5:e104ec24b3fa | 268 | } |
valentinbruchet | 5:e104ec24b3fa | 269 | |
valentinbruchet | 5:e104ec24b3fa | 270 | else if(flag == 0) |
valentinbruchet | 5:e104ec24b3fa | 271 | { |
valentinbruchet | 5:e104ec24b3fa | 272 | led1 = 0; |
valentinbruchet | 5:e104ec24b3fa | 273 | led2 = 0; |
valentinbruchet | 5:e104ec24b3fa | 274 | led3 = 0; |
valentinbruchet | 5:e104ec24b3fa | 275 | led4 = 0; |
valentinbruchet | 6:4f5634f6a565 | 276 | led5 = 0; |
valentinbruchet | 6:4f5634f6a565 | 277 | led6 = 0; |
valentinbruchet | 6:4f5634f6a565 | 278 | led7 = 0; |
valentinbruchet | 6:4f5634f6a565 | 279 | led8 = 0; |
valentinbruchet | 6:4f5634f6a565 | 280 | //chrono=tab[i]; |
valentinbruchet | 6:4f5634f6a565 | 281 | //wait(1); |
valentinbruchet | 5:e104ec24b3fa | 282 | } |
valentinbruchet | 5:e104ec24b3fa | 283 | else if(flag == 2) |
valentinbruchet | 5:e104ec24b3fa | 284 | { |
valentinbruchet | 6:4f5634f6a565 | 285 | if(rfid.readable()) |
valentinbruchet | 5:e104ec24b3fa | 286 | { |
valentinbruchet | 5:e104ec24b3fa | 287 | printf("RFID Tag number : %d\n\r", rfid.read()); |
valentinbruchet | 5:e104ec24b3fa | 288 | } |
valentinbruchet | 6:4f5634f6a565 | 289 | |
valentinbruchet | 6:4f5634f6a565 | 290 | /*switch (rfid.read()) |
valentinbruchet | 6:4f5634f6a565 | 291 | { |
valentinbruchet | 6:4f5634f6a565 | 292 | case 1659775: |
valentinbruchet | 6:4f5634f6a565 | 293 | genieWriteObject(GENIE_OBJ_LED, 0x00, led); |
valentinbruchet | 6:4f5634f6a565 | 294 | break; |
valentinbruchet | 6:4f5634f6a565 | 295 | case 20275460: |
valentinbruchet | 6:4f5634f6a565 | 296 | genieWriteObject(GENIE_OBJ_LED, 0x00, led); |
valentinbruchet | 6:4f5634f6a565 | 297 | break; |
valentinbruchet | 6:4f5634f6a565 | 298 | case 3483687: |
valentinbruchet | 6:4f5634f6a565 | 299 | genieWriteObject(GENIE_OBJ_LED, 0x00, led); |
valentinbruchet | 6:4f5634f6a565 | 300 | break; |
valentinbruchet | 6:4f5634f6a565 | 301 | case 17903953: |
valentinbruchet | 6:4f5634f6a565 | 302 | genieWriteObject(GENIE_OBJ_LED, 0x00, led); |
valentinbruchet | 6:4f5634f6a565 | 303 | break; |
valentinbruchet | 6:4f5634f6a565 | 304 | case 23544435: |
valentinbruchet | 6:4f5634f6a565 | 305 | genieWriteObject(GENIE_OBJ_LED, 0x00, led); |
valentinbruchet | 6:4f5634f6a565 | 306 | break; |
valentinbruchet | 6:4f5634f6a565 | 307 | }*/ |
valentinbruchet | 5:e104ec24b3fa | 308 | } |
valentinbruchet | 5:e104ec24b3fa | 309 | } |
valentinbruchet | 5:e104ec24b3fa | 310 | } |