sends the RFID tag number serially to screen

Dependencies:   ID12RFID mbed

main.cpp

Committer:
lewisjfish
Date:
2015-06-12
Revision:
0:9aa9a6cd3a3d

File content as of revision 0:9aa9a6cd3a3d:

#include "mbed.h"
#include "ID12RFID.h"

 
Serial infoout(PTA2,PTA1); //define the serial port, connected to the screen mbed
 
Serial weatherIn(PTE22,PTE23);
 
 
//DigitalOut myled(LED1);
char message[9]; //character array to store the data we send
 
int tagNumber; //stores the tagnumber read from the RFID reader
 
char c;
int i;
 
 
 
ID12RFID rfid(PTE1); //Initialise RFID reader and associated functions
 
 
 
int main() {       
        while(1){
        
        int i=0;

        if(rfid.readable()){
               //if we can read a tag, get the tagnumber
               tagNumber = rfid.read();
              sprintf(message,"a%d",tagNumber); //turn the tagnumber into a string, string starts with a to identify string as an RFID tagnumber
              
               
            
            for(int n =0; n<9 ; n++){
            //send the data to the second mbed(screen) using putc
            infoout.putc(message[i]);
            i=(i+1)%9; //modulo 9 to ensure only 9 characters are sent
            
            //,waiting 0.05 seconds after each character
            wait(0.05);
            }
            
            if(i==0){
            infoout.putc('A'); //end the message with 'A' to denote the end of an RFID
            
            wait(0.01);
            }
        }
               
        
       // if(weatherIn.readable()){
       
          //      c=weatherIn.getc();
           //     infoout.putc(message[i]);
           //     message[i] = c;
           //     i=(i+1)%9;
                
               // wait(0.05);
       // }             
            
 
            
            
       
    }
    }