But for some reason i cant find anything that gives me an example on how to use it.
I just need a simple program that will allow me to read that tag, but the examples i've found so far doesn't work.
That RFID reader looks a lot like the one that seeedstudio sells. When you power up the Arduino, does the LED on the reader come on? When you scan the tag, does the LED flash?
This is code I use to read from my seeedstudio RFID reader:
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
//create a Serial object RFID
SoftwareSerial RFID = SoftwareSerial(rxPin, txPin);
char code[20];
int val = 0;
int bytesread = 0;
char Red[] = "3900A52D9223";
char Blue[] = "39009F46D131";
char Yellow[] = "390050448FA2";
char Card1[] = "210014E221F6";
char Card2[] = "210014C9906C";
int ledCnt = 5;
int LED[] = {13, 11, 9, 7, 5};
void setup()
{
Serial.begin(9600); //open serial hardware
RFID.begin(9600); //open serial software
pinMode(rxPin, INPUT); //set pin on arduino for receiving RFID data
pinMode(txPin, OUTPUT); //this is not important
for(int i=0; i<ledCnt; i++)
{
pinMode(LED[i], OUTPUT);
}
}
void loop()
{
val = 0;
bytesread = 0;
while(bytesread < 12)
{
// read 12 digit code
val = RFID.read();
if(val == 3)
{ // if header or stop bytes before the 10 digit reading
break; // stop reading
}
if(val != 2)
{
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
code[bytesread] = '\0'; // add the NULL
}
}
if(bytesread >= 12)
{ // if 12 digit read is complete
Serial.print("Tag: [");
for(int i=0; i<bytesread; i++)
{
Serial.print(code[i]);
}
Serial.println("]"); //print the whole 13 bytes
int tag = FindValidTag(code);
Serial.print("Tag number: ");
Serial.println(tag);
for(int i=0; i<ledCnt; i++)
digitalWrite(LED[i], LOW);
if(tag > 0 && tag <= ledCnt)
digitalWrite(LED[tag-1], HIGH);
}
}
int FindValidTag(char *code)
{
if(strcmp(code, Red) == 0)
return 1;
else if(strcmp(code, Blue) == 0)
return 2;
else if(strcmp(code, Yellow) == 0)
return 3;
else if(strcmp(code, Card1) == 0)
return 4;
else if(strcmp(code, Card2) == 0)
return 5;
else
return 0;
}