Shivanand Gowda / Mbed OS RFID125KHz
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut led1(LED1);
00004 Serial Rfid125(PC_12,PD_2);
00005 Thread RFID_Thread;
00006 
00007 char TAG_ID[15]={'\0'};
00008 
00009 void Read_CARD_RFID_125(void)
00010 {
00011   int i=0;
00012   memset(TAG_ID,'\0',15);
00013 
00014 while(1)
00015 {
00016   while(Rfid125.readable())
00017   { 
00018    char c=Rfid125.getc(); 
00019         if(c=='\n')
00020         return;
00021     
00022          else if(c>='\0' && c<='9' && c>='A' && c<='F')
00023             {
00024             TAG_ID[i]=c;
00025             i++;
00026             }
00027             
00028          else
00029          {
00030          printf("Unable to read the CARD\r\n");
00031          printf("CARD Corrupted \r\n");
00032          }
00033   }  
00034 }   
00035 }
00036 
00037 // main() runs in its own thread in the OS
00038 int main() {
00039     
00040     RFID_Thread.start(Read_CARD_RFID_125);
00041     
00042     while (true) {
00043         led1 = !led1;
00044         wait(0.5);
00045     }
00046 }
00047 
00048 
00049 
00050 
00051 
00052