Code for RFID Robot

Dependencies:   DebounceIn HTTPClient ID12RFID SDFileSystem TextLCD WiflyInterface iniparser mbed

RFID.cpp

Committer:
4180skrw
Date:
2013-12-10
Revision:
0:9fd64882c5aa

File content as of revision 0:9fd64882c5aa:

#include "RFID.h"

//Takes in vector by reference and populates it with unique RFID values
//until pb21 is pressed.
int readTagSequence(std::vector<int>& v)
{
   int currTag;
   int size = 0;
   printLCD("Scan tag", NULL);
   while (select) {
       if(rfid.readable()) {
           currTag = rfid.read();
           size++;
           v.resize(size);
           v[size-1] = currTag;
           char line1[16];
           sprintf(line1, "%d", v[size-1]);
           printLCD(line1, "added to list");
           wait(1.5);
           printLCD("Scan tag", NULL);
       }
       else if(!back) return 0;
   }
   return 1;
}

//Reads a single RFID tag, and returns value
int readTag()
{
   printLCD("Scan tag", NULL);
   int currTag = 0;
   while (!currTag) {
       if (rfid.readable()) {
           currTag = rfid.read();
           char line1[16];
           sprintf(line1, "%d", currTag);
           printLCD(line1, "read");
           wait(1.5);
           return currTag;
       }
       else if (!back) {
           return 0;
       }
   }
   return currTag;
}