RFID Card Reader

I am an intern working for a flow services company this summer. I am currently working on using RFID cards to load data (K factors) into a totalizer for flow meter calibration. The idea is to save several different values to several different blocks on the Mifare 1k tags and be able to read them in as usable data. I do have some knowledge of programming through taking a C and Matlab programming classes college. I am using the SL018, Arduino Micro microcontroller, and an LCD screen. I have downloaded the marcboon SL018 library and have found it incredibly useful. However, I am running into a few problems. I believe I am having trouble authenticating the cards as my printed output usually looks like “AA FF FF FF FF FF FF 12 34 56 78 91 01 11 21 31” and I’m not really sure where that is coming from. Also, I am unable to store the data from the blocks. I noticed the user-defined functions are of void type so I was tinkering with them to be able to save these different data blocks into 1 big array. If someone could help me with this at all that would be great. The following is the code I have written thus far. I understand it is very unorganized and messy and I intend on going back and cleaning it all up as soon as I get what I’m actually looking for. Your help with this is greatly appreciated.

#include <Wire.h>
#include <SL018.h>
#include<LiquidCrystal.h>

#define NONE 0
#define SEEK 1
#define READ 2
#define TAG 17

byte keyType;
//byte key = 0xFF;
int led = 13;
int buzPin = 3;
byte action = NONE;
boolean autoRead = false;
boolean tagPresent = false;
boolean authenticated;
byte numBlocks = 0;
byte block;
int i;
const char* UID;
byte tagType;
int n;
int m = 0;
byte sector;
SL018 rfid;

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup()
{
pinMode(buzPin, OUTPUT);
pinMode(led, OUTPUT);
pinMode(TAG, INPUT);
lcd.begin(16,2);
lcd.setCursor(0,0);
Wire.begin();
Serial.begin(19200);
lcd.setCursor(1,0);
Serial.println(“Totalizer RFID Tag Reader”);
lcd.print(“Totalizer RFID”);
lcd.setCursor(3,1);
lcd.print(“Tag Reader”);
delay(2000);
lcd.clear();
// prompt for tag
Serial.println(“Show me your tag”);
lcd.print(“Show me your tag”);
}

void loop()
{

rfid.seekTag();

if (rfid.available() && numBlocks <= 10)
{

rfid.authenticate(numBlocks >> 2);
rfid.readBlock(block);
sector++;
Serial.print("Block ");
if (numBlocks <= 9)
{
Serial.print(“0”);
Serial.print(block);
}
else
{
Serial.print(block);
}

//printHex(numBlocks);
Serial.print(": ");

lcd.setCursor(0,1);
printArrayH(rfid.getBlock(), 16);
Serial.println();
// Serial.print(" ");
++block;
numBlocks++;

}

// start seek mode

// wait until tag detected
while(!rfid.available());
if (m <1)
{
// print tag id
//digitalWrite(buzPin, HIGH);
digitalWrite(led, HIGH);
Serial.print("UID: ");
Serial.println(rfid.getTagString());
UID = rfid.getTagString();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("UID: ");
lcd.print(rfid.getTagString());
delay(500);
//digitalWrite(buzPin, LOW);
digitalWrite(led, LOW);
m++;
}

}

void printArrayH(byte array, byte len)
{
for (byte i = 0; i < len;)
{
printH(array[i++]);
if (i < len)
{
Serial.print(’ ');
}
}
}

void printH(byte val)
{

if (val < 0x10)
{
lcd.print(“0”);
}
Serial.print(val, HEX);
lcd.print(val, HEX);
//delay(100);
}