UHF RFID Nucleo Serial Port LSID-0702

Dependencies:   mbed

Fork of EM18_Rfid by Shivanand Gowda

main.cpp

Committer:
shivanandgowdakr
Date:
2018-07-12
Revision:
0:1a3020ba8001
Child:
1:3781e9bf2c47

File content as of revision 0:1a3020ba8001:

#include "mbed.h"




// initialize the library with the numbers of the interface pins
DigitalOut led(LED1);
Serial EM18Rfid(PC_12,PD_2);

int count = 0;          //integer for storing character of ID

char input[12];//memory for storing 12 characters of ID

int main()
{
 EM18Rfid.baud(9600); //Baud Rate 9600                             

        while(true)
        
        {    
        
        while(EM18Rfid.readable() && count < 12)          // Read 12 characters and store them in input array
            
            {
                input[count] = EM18Rfid.getc();
                count++;
                    if (count==12)
                    {        
                    led=1;
                    input[count]='\0';
                    printf("Read Tag Id is : %s\r\n",input);  
                    count = 0;// once 12 characters are read get to start and wait for 1 second  before reading next ID
                    wait(1);
                    led=0;                
                    }
            }
        
        } 
}