Code for RFID Writer Parallax 28440

I've tested many codes from here and i've found some difficulties that i'm now solve so for your help i'm leaving here the code that works for me for reading and writing RFID tags with the Parallax RFID Reader/Writer 28440. It only works with tags 28441 from parallax because they are the only ones that had EEprom inside. The program save the data in adress 3 from the Tag if you press a button conected to pin 13. Also had a LCD conected with the standard conections from the example of the Liquidcristal library/example. I'm using the standard Uart to conect the RFID so it's not possible to use the Monitor.

I hope it helps people that have questions with RFID Reader/Writer.

Thanks,

//Test RFID Writer/Reader Parallax 28440

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//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_LOGIN 0x03
#define RFID_PROTECT 0x05
//#define RFID_LEGACY 0x0F

//NewSoftSerial mySerial(rxPin, txPin);
int val = 0;
int v1 = 0;
int v2 = 0;
int v3 = 0;
int v4 = 0;
int i= 0 ;
int c1 = 0;
byte code = 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);
lcd.begin(16, 4);
lcd.clear();
pinMode(13, INPUT);
// mySerial.begin(9600);

// pinMode(2, OUTPUT);
// pinMode(4, OUTPUT);
// pinMode(txPin, OUTPUT); //pin 6
// pinMode(rxPin, INPUT); //pin 8

lcd.print("Precision Reader");
}

void loop()
{
/*
Serial.print("!RW");
Serial.print(RFID_WRITE, BYTE);
Serial.print(3, BYTE);
Serial.print(9, BYTE);
Serial.print(9, BYTE);
Serial.print(9, BYTE);
Serial.print(9, BYTE);

//Error code read
if(Serial.available() > 0) { // if data available from reader
val = Serial.read();
if(val != 255){
// lcd.print("Write Error Code:");
// lcd.print(val, HEX);
}
}
*/

Serial.print("!RW");
Serial.print(RFID_READ, BYTE);
Serial.print(3, BYTE);

//0th read
if(Serial.available() > 0) { // if data available from reader
code = Serial.read();
if(code != 255){
lcd.setCursor(0, 1);
lcd.print("Code: ");
lcd.print(code, DEC);
}
}

//1st byte
if(Serial.available() > 0) { // if data available from reader
val = Serial.read();
if(val != 255){
lcd.setCursor(0, 2);
//lcd.print("1st:");
v1 = (val);
lcd.print(v1);
}
}

//2nd byte
if(Serial.available() > 0) { // if data available from reader
val = Serial.read();
if(val != 255){
//lcd.print(":");
v2 = (val);
lcd.print(v2);
}
}

//3rd byte
if(Serial.available() > 0) { // if data available from reader
val = Serial.read();
if(val != 255){
v3 = (val) ;
lcd.print(",");
lcd.print(v3);
}
}

//4th byte

if(Serial.available() > 0) { // if data available from reader
val = Serial.read();
if(val != 255){
// lcd.print(":");
v4= (val);
lcd.print(v4);

}
}
delay(300); // wait for a 1/2 second
c1 = digitalRead(13);

if (c1 == LOW ){
i=i++;
if(i>9){i=0;}

Serial.print("!RW");
Serial.print(RFID_WRITE, BYTE);
Serial.print(3, BYTE);
Serial.print(i, BYTE);
Serial.print(i, BYTE);
Serial.print(i, BYTE);
Serial.print(i, BYTE);

//Error code read
if(Serial.available() > 0) { // if data available from reader
val = Serial.read();
if(val != 255){
// lcd.print("Write Error Code:");
// lcd.print(val, HEX);
lcd.setCursor(0, 3);
lcd.print("Writed");
delay(500);
lcd.setCursor(0, 3);
lcd.print(" ");
code = 0;
}
}
}

}

I hope it helps people that have questions with RFID Reader/Writer.

It would help more if the commented out code was removed, the Tools + Auto Format tool was used, and the code was posted properly, using the # icon.

Try again.

so I just picked up a 28440 and am not having much luck. Im using a mega2560 and the code found here Arduino Playground - ParallaxRFIDreadwritemodule. I have double and triple checked my wiring, the led on the reader will go from red to green when a card is presented but thats all I get nothing on the serial monitor other than the initial "RFID Read/Write Test" I also tried removing the suppress function

void suppressAll()                                //suppresses the "null result" from being printed if no RFID tag is present
{
    if(mySerial.available() > 0)
    { mySerial.read();
      suppressAll();
    }
}

hoping I might get some output but still nothing, any ideas?

the code i used

#include <SoftwareSerial.h>
#define RFID_READ 0x01
#define txPin 6
#define rxPin 8

SoftwareSerial mySerial(rxPin, txPin);
int val;
int runs = 0;

void setup()
{
  Serial.begin(9600);
  Serial.println("RFID Read/Write Test");
  mySerial.begin(9600);
  pinMode(txPin, OUTPUT);    
  pinMode(rxPin, INPUT);      
}

void suppressAll()                                //suppresses the "null result" from being printed if no RFID tag is present
{
    if(mySerial.available() > 0)
    { mySerial.read();
      suppressAll();
    }
}

void loop()
{
 int val;
  mySerial.print("!RW");
  mySerial.write(byte(RFID_READ));
  mySerial.write(byte(32));

  if(mySerial.available() > 0)
  {      
    val = mySerial.read();                        //The mySerial.read() procedure is called, but the result is not printed because I don't want the "error message: 1" cluttering up the serial monitor
      if (val != 1)                                   //If the error code is anything other than 1, then the RFID tag was not read correctly and any data collected is meaningless. In this case since we don't care about the resultant values they can be suppressed
       {suppressAll();}                              
  }      


 if(mySerial.available() > 0) {      
    val = mySerial.read();
    Serial.print("1st:");
    Serial.println(val, HEX);
    }

if(mySerial.available() > 0) {        
    val = mySerial.read();
    Serial.print("2nd:");
    Serial.println(val, HEX);
    }

if(mySerial.available() > 0) {      
    val = mySerial.read();
    Serial.print("3rd:");
    Serial.println(val, HEX);
    }

if(mySerial.available() > 0) {          
    val = mySerial.read();
    Serial.print("4th:");
    Serial.println(val, HEX);
    Serial.println("-----------------");
    }  

delay(750);
}
#define txPin 6
#define rxPin 8

SoftwareSerial mySerial(rxPin, txPin);

You've got a Mega. It has 4 hardware serial ports. Why are you using SoftwareSerial?

If you insist on using SoftwareSerial, I presume that you looked at the documentation for SoftwareSerial, and noted that only certain pins could be used, but then decided that those rules didn't apply to you. Well, guess again.