 
 void loop()
 {
-  readRfid();
+ readRfid();
+ printRfid();
 }
 
 void readRfid()


#define SS_PIN 8
#define RST_PIN 4
#define RX 11
#define TX 10
RFID rfid(SS_PIN, RST_PIN); //create an instance rfid for the class RFID

// varables to store data

  {
    if (rfid.readCardSerial())
    {
      for (int i=0; i<=4; i++)//card value: "xyz xyz xyz xyz xyz" (15 digits maximum; 5 pairs of xyz)hence 0<=i<=4 //
      {
        RFID = rfid.serNum[i];
        cardNum += RFID; // store RFID value into string "cardNum" and concatinate it with each iteration
      }
    }
  }
  rfid.halt();
}

void printRfid()
{
 if (cardNum != '\0')//if string cardNum is not empty, print the value
 {
    Serial.println("Card found");
    Serial.print("Cardnumber: ");
    Serial.println(cardNum);
    cardNum.remove(0);
   //This is an arduino function.
  //remove the stored value after printing. else the new card value that is read
  // will be concatinated with the previous string.
  delay(500); 
 }
}
