Looking through the forums here and on parallax it looks like several people have had trouble getting the Parallax RFID Read/Write Module 28440 to correctly interface with the Arduino. The read/write module is a vast improvement over the old, read only module. The old module has numerous examples of how to code it for an Arduino. The new module is 4 times as fast, backwards compatible with with old reader tags and also supports write functionality.
I finally got it working so I thought I'd share my code. Note that this is a very rough and ugly code, but it works. I will be refining it over the next few days, but figured I'd post it as soon as I got it working to relieve frustration and also let others play with the code.
Here is the code for reading new style (EM4x50) tags.
//Interface Arduino USB with Parallax 28440 125 Khz UART RFID Reader/Writer
//Program reads a EM4x50 tag and reports the ID on the serial monitor.
//Coded by Uberdude#include "NewSoftSerial.h"
#define txPin 6
#define rxPin 8//Reader/Writer Commands
#define RFID_READ 0x01
//#define RFID_WRITE 0x02
//#define RFID_LEGACY 0x0FNewSoftSerial mySerial(rxPin, txPin);
int val = 0;
//char code[6]; //Note this is 11 for the extra null char?
//int bytesread = 0;
//int flag = 0;//Tags
//char TAG1[11] = "0800E28C60";
//char TAG2[11] = "0800D9E43E";void setup()
{
Serial.begin(9600);
mySerial.begin(9600);// pinMode(2, OUTPUT);
// pinMode(4, OUTPUT);
pinMode(txPin, OUTPUT); //pin 6
pinMode(rxPin, INPUT); //pin 8Serial.println("RFID Read/Write Test");
}void loop()
{
mySerial.print("!RW");
mySerial.print(RFID_READ, BYTE);
mySerial.print(3, BYTE);//0th read
if(mySerial.available() > 0) { // if data available from reader
val = mySerial.read();
if(val != 255){
Serial.print("Error Code:");
Serial.println(val, HEX);
}
}//1st byte
if(mySerial.available() > 0) { // if data available from reader
val = mySerial.read();
if(val != 255){
Serial.print("1st:");
Serial.println(val, HEX);
}
}//2nd byte
if(mySerial.available() > 0) { // if data available from reader
val = mySerial.read();
if(val != 255){
Serial.print("2nd:");
Serial.println(val, HEX);
}
}//3rd byte
if(mySerial.available() > 0) { // if data available from reader
val = mySerial.read();
if(val != 255){
Serial.print("3rd:");
Serial.println(val, HEX);
}
}//4th byte
if(mySerial.available() > 0) { // if data available from reader
val = mySerial.read();
if(val != 255){
Serial.print("4th:");
Serial.println(val, HEX);
}
}delay(500); // wait for a 1/2 second
}
Note that if you have a rectangular read/write tag from parallax like I have, they come pre loaded with 0xFEEDBEEF in the first data address. If you didn't get your tags from there, or have a round tag, it should show up as 4 zeros. Alternately just change the the mySerial.print(3, BYTE); to mySerial.print(33, BYTE); which will read the unique serial ID. One thing that screwed me up for a long time is that the first byte of data in the ID could be a 1 which I was thinking was the error code. Hence why I went to this ugly code explicitly stating what the bytes I was getting.
Enjoy