How to make feed back from Active RFID

please help…please…:frowning:
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.

just simple , if one of them or just one is not detected by Reader , LED will turn on. but i cant do that. what’s wrong with my listing program… ? maybe you know what i miss …

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

this is my listingprogram :

[
#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… :’(

Your tags are defined using a # define. That simply subistutes those letters in the code when you use them. Your compair in the if statement is therefore not going to work.

Put your known tags in a C string variable and compair your incoming value with the string.

You're not saving the input characters:

    while (RFID.available() > 0) {
      msg += c;  ////////////// You forgot to read the input character!
      Serial.write(RFID.read());
    }

What you meant to do was:

    while (RFID.available() > 0) {
      char c = RFID.read()
      msg += c;
      Serial.write(c);
    }

Grumpy_Mike: Your tags are defined using a # define. That simply subistutes those letters in the code when you use them. Your compair in the if statement is therefore not going to work.

Put your known tags in a C string variable and compair your incoming value with the string.

so, i didn't need to change my Msg String to C char ? just compare incoming value with my string Tag's code? oke i will do that

johnwasser: You're not saving the input characters:

    while (RFID.available() > 0) {
      msg += c;  ////////////// You forgot to read the input character!
      Serial.write(RFID.read());
    }

What you meant to do was:

    while (RFID.available() > 0) {
      char c = RFID.read()
      msg += c;
      Serial.write(c);
    }

thanks, i know.. but i am confuse whit this part of program did u understand what this program mean?

 msg += c;

Try printing out your message read from the tag to see if you have it in correctly.

doflaminggo3: thanks, i know.. but i am confuse whit this part of program did u understand what this program mean?msg += c;

Look at the declaration of 'msg':String msg; Look at the definition of the String type: http://www.arduino.cc/en/Reference/StringObject Particularly look at the example for StringAppendOperator: http://www.arduino.cc/en/Tutorial/StringAppendOperator

Grumpy_Mike: Try printing out your message read from the tag to see if you have it in correctly.

this is my screen capture : the result of my program in serial monitor arduino uno

|500x278

You should be using Serial.Print if you want to see what is coming out of the reader. Gather them all up in your variable and THEN print it out. The print out a CR so that each read is on a separate line.

Grumpy_Mike: Gather them all up in your variable and THEN print it out. The print out a CR so that each read is on a separate line.

what did u mean Gather them all up in my variable?

what is CR ?

CR is a carriage return character to tell a monitor that a new line is needed.

Put all the characters into a char array do not print them out as they arrive.

Those things you are recieving are not RFID codes because RFID codes do not include , and $ in them.

Are you sure that you are ready for this sort of project? I would suggest you did a bit more background work first. It is like saying you want to climb Everest and then asking what are boots.

Have you seen this project? https://code.google.com/p/open-access-control/

It seems the $ in the received data is the data packet delimiter. The potential issue is itappears to be at the start of a data packet instead of at the end. If it were at the end of the packet the below code might be of use.

//zoomkat 3-5-12 simple delimited '

string  //from serial port input (via serial monitor) //and print result out serial port

String readString;

void setup() {   Serial.begin(9600);   Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded }

void loop() {

  //expect a string like wer$qwe rty$123 456$hyre kjhg$   //or like hello world$who are you?$bye!$     if (Serial.available())  {     char c = Serial.read();  //gets one byte from serial buffer     if (c == ' ```

) {       //do stuff       Serial.println(readString); //prints string to serial port out       readString=""; //clears variable for new input          }      else {   
      readString += c; //makes the string readString     }   } } ```