Rfid

Hi, the code below compile correctly but the problem is that when I pass the card on the reader: the number of the card show up 2 times on the monitor and I need to solve this problem . it has to be shown just one time:

#include <SoftwareSerial.h>

#define RFIDEnablePin 9 
#define RFIDSerialRate 2400 

#define RxPin 10 
#define TxPin 10 

SoftwareSerial RFIDReader(RxPin,TxPin);

String RFIDTAG=""; 
String DisplayTAG = "";
String klasse1 [2] = {"7A00631EA3","2700B9FCA6"};
String klasse2 [2] = {"0415C4746F","0415C49D56"};

int ledR = 13;
int ledG = 12;
int ledY = 2;
int berechtigung = 0;
String anzeige;

void setup() 
{
  RFIDReader.begin(RFIDSerialRate);

  pinMode(RFIDEnablePin,OUTPUT); 
  pinMode(ledR, OUTPUT);
  pinMode(ledG, OUTPUT);
  pinMode(ledY, OUTPUT);

  digitalWrite(RFIDEnablePin, LOW);
  Serial.begin(9600);           
  Serial.println("Schleuse betriebsbereit!");  

}

void loop() 
{
  if(RFIDReader.available() > 0) 
  { 
    ReadSerial(RFIDTAG);  
  }
  anzeige = RFIDTAG;
  for (int i = 0;i<2;i++) // für Klasse 1
   {
     if (klasse1[i] == RFIDTAG) 
     {
      RFIDTAG = "";
      berechtigung = 1;
     } 
    }

for (int i = 0;i<2;i++) // für Klasse 2
   { 
     if (klasse2[i] == RFIDTAG) 
     {
      berechtigung = 2;
      RFIDTAG = "";
     }  
    }
    if (RFIDTAG != "")   
     {
      berechtigung = 3;
      RFIDTAG = "";
    }

  if (berechtigung==1) 
  {
    Serial.println("Zutritt ohne Weste "+anzeige);  
    digitalWrite(ledY, LOW); 
    digitalWrite(ledR, LOW); 
    digitalWrite(ledG, HIGH); 
    delay(2000);
    berechtigung = 0;
  }

  if (berechtigung==2) 
 {
    Serial.println("Zutritt mit Weste "+anzeige );  
    digitalWrite(ledY, HIGH); 
    digitalWrite(ledR, LOW); 
    digitalWrite(ledG, HIGH);
    delay(2000);
    berechtigung = 0;
 }
 
  if (berechtigung==3) 
 {
    Serial.println("kein Zutritt "+anzeige);  
    digitalWrite(ledY, LOW); 
    digitalWrite(ledR, HIGH); 
    digitalWrite(ledG, LOW);
    delay(2000);
    berechtigung = 0;
   
 }
 
  if (berechtigung==0) 
   {
    digitalWrite(ledY, HIGH); 
    digitalWrite(ledR, LOW); 
    digitalWrite(ledG, LOW);
   }
  
}





void ReadSerial(String &ReadTagString)
{
  int bytesread = 0;
  int  val = 0; 
  char code[10];
  String TagCode="";

  if(RFIDReader.available() > 0) {         
    if((val = RFIDReader.read()) == 10) {   
      bytesread = 0; 
      while(bytesread<10) {                 
        if( RFIDReader.available() > 0) { 
          val = RFIDReader.read(); 
          if((val == 10)||(val == 13)) {    
            break;                         
          } 
          code[bytesread] = val;                    
          bytesread++;                      
        } 
      } 
      if(bytesread == 10) {                
        for(int x=0;x<10;x++)              
        {
          TagCode += code[x];
        }
        ReadTagString = TagCode;          
        while(RFIDReader.available() > 0) 
        {
          RFIDReader.read();
        } 
      } 
      bytesread = 0;
      TagCode="";
    } 
 } 
}
#define RxPin 10
#define TxPin 10

SoftwareSerial RFIDReader(RxPin,TxPin);

You can NOT use the same pin for receive and transmit. You could use -1 as the transmit pin, if you never write()/print()/println() to the device.

I can't see any reason for the data being printed twice. Of course, you've shown no serial output, so we have no proof that that IS the case. Nor do you have anything to prove that the card is not being read twice.

You also have NO reason to be pissing away resources on the String class. EVERYTHING that you do can be done with strings (NULL terminated arrays of chars).

I see ... I 've realised that the card is being read twice.
what do u think is the possible reason?

what do u think is the possible reason?

It's either the phase of the moon in conjunction with solar rays from Jupiter or your code.

I'm thinking that the phase of the moon has nothing to do with your problem.