Active RFID

i have project to interface active RFID with Arduino.
I already success to read unique code of active RFID tag in Arduino's serial monitor. and the unique code are :

tag 1 : $1C1503110663,01,0010603F, 00
tag 2 : $1C1503110663,01,00106062, 71
tag 3 : $1C1503110663,01,00106054, 74
tag 4 : $1C1503110663,01,00106038, 7E

and want to make if Tag 1 is losing from the Reader area, LED1 will turn ON
if Tag 2 is losing from Reader area, LED2 will turn ON. and continue until tag 4.

but i cant do that !

i already use that code in my program, but still not success.

this is my code :

[#include <SoftwareSerial.h>

#define A_TAG_CODE "$1C1503110663,01,0010603F,00"  //change this ID with your own card TAG
#define B_TAG_CODE "$1C1503110663,01,00106062,71"
#define C_TAG_CODE "$1C1503110663,01,00106054,74"
#define D_TAG_CODE "$1C1503110663,01,00106038,7E"

String msg;


SoftwareSerial RFID(9, 10);

#define ledpin    6

int ledPin = 6;  //Sets pin 13 to LED

void setup()  
{
 pinMode(ledPin, OUTPUT);  // Sets the digital pin as output
 
 digitalWrite(ledpin,LOW); 
 
 Serial.begin(38400);
 Serial.println("Serial READY");

 RFID.begin(38400);
 Serial.println("RFID READY");
}
 char c;
 
 void loop(){
  msg="";
  while(msg.length()<26){
  while(RFID.available()>0){
    
    msg += c;
    Serial.write(RFID.read());
    
    
   
    
    //Serial.println(msg);  //Uncomment to view your tag ID
    //Serial.println(msg.length());
  }
  
  } 
  msg=msg.substring(1,26);  
  if(msg.indexOf(A_TAG_CODE)>=0) add1 () ; 
  else add () ;
  if(msg.indexOf(B_TAG_CODE)>=0) add1 () ; 
  else add () ;
  if(msg.indexOf(C_TAG_CODE)>=0) add1 () ; 
  else add () ;
  if(msg.indexOf(D_TAG_CODE)>=0) add1 () ; 
  else add () ;
 }
 
 
 
 void add () {
 digitalWrite(ledPin, HIGH);    // sets the LED off
             }
             
             
  void add1 () {
  digitalWrite(ledPin, LOW);   // sets the LED on
  delay(2000);                  // waits for a second
 
 }]

Please some body help....please.... :cry:

  while(msg.length()<26){

So, you know exactly how many characters there will be. Yet, you are still pissing away resources using the String class. Why?

    Serial.write(RFID.read());

Read a character. Write it to the serial port. Don't even think about adding it to msg. Why not?

  msg=msg.substring(1,26);

Through away the first character of the String that you didn't write to. Why?

PaulS:

  while(msg.length()<26){

So, you know exactly how many characters there will be. Yet, you are still pissing away resources using the String class. Why?

yes i know, there was 25 character of the Tag's code. so, am i wrong if i make it into string class.. why?

    Serial.write(RFID.read());

Read a character. Write it to the serial port. Don't even think about adding it to msg. Why not?

oke i will add it into msg

  msg=msg.substring(1,26);

Through away the first character of the String that you didn't write to. Why?

what did u mean about "Through away first character of the string that i didn't write to"? i didn't through away any character.

what did u mean about "Through away first character of the string that i didn't write to"? i didn't through away any character.

Yes you did. Array indexes start at 0, not 1.