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;
}
}
}
}