Get value from RFID tag and store it as a string

I have looked for a couple hours now and the closest code I found didn't work. I have an RFID card reader from Parallax. I would like to get a tags value with it and print it to an LCD screen. However, I cannot find a way to get the tags value. I plan on using the RX pin of the arduino. All I need is a simple program that gets the tag ID and convert it to a string. From there, I know how to send it to the LCD.

http://makeprojects.com/Project/Using-the-Parallax-RFID-Reader-with-an-Arduino/617/1#.UG0331HSBxA

Also you could try this http://www.gumbolabs.org/2009/10/17/parallax-rfid-reader-arduino/

Denbo:
Also you could try this http://www.gumbolabs.org/2009/10/17/parallax-rfid-reader-arduino/

I believe (after edits) that that may have gotten it. I'll have to check later, for I am currently working on another project at the moment.

Well it didn't work. But it almost did. If someone wants to help, here's the code:

#define RFID_ENABLE 10   //to RFID ENABLE
#define CODE_LEN 10      //Max length of RFID tag
#define VALIDATE_TAG 1  //should we validate tag?
#define VALIDATE_LENGTH  200 //maximum reads b/w tag read and validate
#define ITERATION_LENGTH 2000 //time, in ms, given to the user to move hand away
#define START_BYTE 0x0A 
#define STOP_BYTE 0x0D

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
//LiquidCrystal(rs, enable, d4, d5, d6, d7) 
LiquidCrystal lcd(2, 3, 5, 6, 7, 8);
 
char tag[CODE_LEN];  
 
void setup() { 
  Serial.begin(2400);  
  pinMode(RFID_ENABLE,OUTPUT);  
 lcd.begin(16,2) ;
}
 
void loop() { 
  enableRFID(); 
  lcd.clear();
  getRFIDTag();
  if(isCodeValid()) {
    disableRFID();
    sendCode();
    delay(ITERATION_LENGTH);
  } else {
    disableRFID();
    lcd.clear();
    lcd.print("Got some noise");  
  }
  Serial.flush();
  clearCode();
} 
 
/**
 * Clears out the memory space for the tag to 0s.
 */
void clearCode() {
  for(int i=0; i<CODE_LEN; i++) {
    tag[i] = 0; 
  }
}
 
/**
 * Sends the tag to the LCD.
 */
void sendCode() {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("TAG:");  
    //Serial.println(tag);
    lcd.setCursor(0,1);
    for(int i=0; i<=CODE_LEN; i++) {
      lcd.setCursor(tag[i],1);
      lcd.print(tag[i]); 
    } 
}
 
/**************************************************************/
/********************   RFID Functions  ***********************/
/**************************************************************/
 
void enableRFID() {
   digitalWrite(RFID_ENABLE, LOW);    
}
 
void disableRFID() {
   digitalWrite(RFID_ENABLE, HIGH);  
}
 
/**
 * Blocking function, waits for and gets the RFID tag.
 */
void getRFIDTag() {
  byte next_byte; 
  while(Serial.available() <= 0) {}
  if((next_byte = Serial.read()) == START_BYTE) {      
    byte bytesread = 0; 
    while(bytesread < CODE_LEN) {
      if(Serial.available() > 0) { //wait for the next byte
          if((next_byte = Serial.read()) == STOP_BYTE) break;       
          tag[bytesread++] = next_byte;                   
      }
    }                
  }    
}
 
/**
 * Waits for the next incoming tag to see if it matches
 * the current tag.
 */
boolean isCodeValid() {
  byte next_byte; 
  int count = 0;
  while (Serial.available() < 2) {  //there is already a STOP_BYTE in buffer
    delay(1); //probably not a very pure millisecond
    if(count++ > VALIDATE_LENGTH) return false;
  }
  Serial.read(); //throw away extra STOP_BYTE
  if ((next_byte = Serial.read()) == START_BYTE) {  
    byte bytes_read = 0; 
    while (bytes_read < CODE_LEN) {
      if (Serial.available() > 0) { //wait for the next byte      
          if ((next_byte = Serial.read()) == STOP_BYTE) break;
          if (tag[bytes_read++] != next_byte) return false;                     
      }
    }                
  }
  return true;   }

Okay, I got it working for the most part. However, there is one huge problem. After the LCD displays the UID of the tag, the UID is replaced with some strange characters: each of them are decimal value 186. During that time, the code disables and re-enables the RFID reader. I did manage to use a longer time delay to get "Got some noise" to display instead of the strange characters. I have no idea what the crap is going on. I used Serial.println(tag*) to show what the LCD was trying to display, and those strange dec186 characters return a blank character in the serial monitor. Here is my code:*
```
*#define RFID_ENABLE 10  //to RFID ENABLE
#define CODE_LEN 10      //Max length of RFID tag
#define VALIDATE_TAG 1  //should we validate tag?
#define VALIDATE_LENGTH  200 //maximum reads b/w tag read and validate
#define ITERATION_LENGTH 5000 //time, in ms, given to the user to move hand away
#define START_BYTE 0x0A
#define STOP_BYTE 0x0D
#define green 12
#define red 13

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
//LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal lcd(2, 3, 5, 6, 7, 8);

char tag[CODE_LEN];

void setup() {
  Serial.begin(2400); 
  pinMode(RFID_ENABLE,OUTPUT); 
lcd.begin(16,2) ;
}

void loop() {
  enableRFID();
  delay(100);
  lcd.clear();
  lcd.print("TAG:");
  getRFIDTag();
  if(isCodeValid()) {
    disableRFID();
    sendCode();
    delay(ITERATION_LENGTH);
  } else {
    disableRFID();
    lcd.clear();
    lcd.print("Got some noise"); 
  }
  Serial.flush();
  clearCode();
}

/**

  • Clears out the memory space for the tag to 0s.
    */
    void clearCode() {
      for(int i=0; i<CODE_LEN; i++) {
        tag[i] = 0;
      }
    }

/**

/***/
/
  RFID Functions  /
/
/

void enableRFID() {
  digitalWrite(RFID_ENABLE, LOW);
  digitalWrite(red, HIGH);digitalWrite(green,LOW);
}

void disableRFID() {
  digitalWrite(RFID_ENABLE, HIGH); 
  digitalWrite(red, LOW);digitalWrite(green,HIGH);
}

/**

  • Blocking function, waits for and gets the RFID tag.
    */
    void getRFIDTag() {
      byte next_byte;
      while(Serial.available() <= 0) {}
      if((next_byte = Serial.read()) == START_BYTE) {     
        byte bytesread = 0;
        while(bytesread < CODE_LEN) {
          if(Serial.available() > 0) { //wait for the next byte
              if((next_byte = Serial.read()) == STOP_BYTE) break;     
              tag[bytesread++] = next_byte;                 
          }
        }               
      }   
    }

/**

  • Waits for the next incoming tag to see if it matches
  • the current tag.
    /
    boolean isCodeValid() {
      byte next_byte;
      int count = 0;
      while (Serial.available() < 2) {  //there is already a STOP_BYTE in buffer
        delay(1); //probably not a very pure millisecond
        if(count++ > VALIDATE_LENGTH) return false;
      }
      Serial.read(); //throw away extra STOP_BYTE
      if ((next_byte = Serial.read()) == START_BYTE) { 
        byte bytes_read = 0;
        while (bytes_read < CODE_LEN) {
          if (Serial.available() > 0) { //wait for the next byte     
              if ((next_byte = Serial.read()) == STOP_BYTE) break;
              if (tag[bytes_read++] != next_byte) return false;                   
          }
        }               
      }
      return true;  }

    ```