This is a RFID based attendance system. The current program is only for two users but can be easily scaled for more users. Apart from FRDM-K64F board, we have MFRC522, Nokia 5110 LCD and SD card as external hardware. Each time a legitimate card is flashed the name of the person will be displayed on the LCD and his information will be stored in SD card if it's already not there. I have used existing libraries for all the harware. Here is the list. MFRC522 - By Martin Olejar SDFileSystem - By Andrew Lindsay NOKIA_5110 - By Chris Yan.
Dependencies: MFRC522 NOKIA_5110 SDFileSystem mbed
Fork of FTF2014_lab4 by
Diff: main.cpp
- Revision:
- 8:ea7d0c9a35c4
- Parent:
- 7:caeacf521320
- Child:
- 9:f7c69716fad8
--- a/main.cpp Sun May 03 15:40:55 2015 +0000 +++ b/main.cpp Sun May 03 18:27:02 2015 +0000 @@ -17,25 +17,18 @@ MFRC522 RfChip (PTD2, PTD3, PTD1, PTE25, PTD0); SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS -char buffer[1024]; //UNKNOWN foe now -//uint8_t line[100]; +char buffer[1024]; uint8_t user[10]; -uint8_t userlist[2][10]; -char sam[16]="BC02CD022B02702"; -char tempsam[16]; +char kanu[16]="BC02CD022B02702"; char abhishek[17]="6902BC029C021A02"; -char abhishektemp[17]; - -int usercount=0; -//int found=0; -int flagSam=0; -int flagAbi=0; //checks if the card scanner is run for the first time +char temp[17]; +int flag1=0; +int flag2=0; //checks if the card scanner is run for the first time int main() { pc.printf("Initializing \n"); - //wait(2); LcdPins myPins; myPins.sce = PTC12; @@ -50,7 +43,7 @@ // Start the LCD myLcd.InitLcd(); myLcd.DrawString("HELLO"); - wait( 5 ); + wait( 3 ); myLcd.ShutdownLcd(); // Init. RC522 Chip @@ -64,7 +57,6 @@ pc.printf("Remove an existing file with the same name \n"); } - while (true) { LedGreen = 1; @@ -95,25 +87,23 @@ } printf("\n"); - - - sprintf(abhishektemp,"%X02%X02%X02%X02",user[0],user[1],user[2],user[3]); - printf("Abitemp is %s",abhishektemp); + sprintf(temp,"%X02%X02%X02%X02",user[0],user[1],user[2],user[3]); + printf("temp is %s",temp); - if(strcmp(abhishektemp, abhishek)==0) + if(strcmp(temp, abhishek)==0) { printf("\n found abhishek\n"); - if (flagAbi==1) + if (flag2==1) { printf("Already logged in!\n"); myLcd.InitLcd(); myLcd.DrawString("ABHISHEK"); - wait( 5 ); + wait( 3 ); myLcd.ShutdownLcd(); } - else if (flagAbi==0) + else if (flag2==0) { printf("\nWriting data to the sd card \n"); fp = fopen("/sd/attendance.txt", "a+"); @@ -122,33 +112,32 @@ pc.printf("Unable to write the file \n"); } else - { - // while(!feof(fp)) {}; + { fprintf(fp, "\nAbhishek PRESENT \n"); fclose(fp); } - flagAbi=1; + flag2=1; myLcd.InitLcd(); myLcd.DrawString("ABHISHEK"); - wait( 5 ); + wait( 3 ); myLcd.ShutdownLcd(); } } - else if(strcmp(abhishektemp,sam)==0) + else if(strcmp(temp,kanu)==0) { - printf("\n found Sam\n"); - if (flagSam==1) + printf("\n found Kanu\n"); + if (flag1==1) { printf("Already logged in!\n"); myLcd.InitLcd(); - myLcd.DrawString("SAM"); - wait( 5 ); + myLcd.DrawString("KANU"); + wait( 3 ); myLcd.ShutdownLcd(); } - else if (flagSam==0) + else if (flag1==0) { printf("\nWriting data to the sd card \n"); fp = fopen("/sd/attendance.txt", "a+"); @@ -157,17 +146,16 @@ pc.printf("Unable to write the file \n"); } else - { - // while(!feof(fp)) {}; - fprintf(fp, "\nSAM PRESENT \n"); + { + fprintf(fp, "\nKANU PRESENT \n"); fclose(fp); } - flagSam=1; - printf("FlagSam=%i\n",flagSam); + flag1=1; + printf("flag1=%i\n",flag1); myLcd.InitLcd(); - myLcd.DrawString("SAM"); - wait( 5 ); + myLcd.DrawString("KANU"); + wait( 3 ); myLcd.ShutdownLcd(); }