MFRC522 Doesn't detect 2nd Card

Hello all, what I need to do is basically,

  • Read the card uid.
  • Get selection (by pushing a button)
  • Restart loop
    It reads the card in the first time after uploading the sketch and gets the selection, but it doesn't detect after the first loop.
    What can be the problem ? I searched it and I checked (and made some changes) the code but I couldn't find out what is wrong with my code.

(I know for sure that something is wrong with the getVote part. Without it, the code works as I expect)

 ...

void loop() {

    // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
    return;

  // Verify if the NUID has been readed
  if ( ! mfrc522.PICC_ReadCardSerial())
    return;

  int cardUID = getCardID();

  Serial.println("CARD UID READ");
  printCardName(cardUID);

  Serial.println("SELECT WITH BUTTONS");
  
//getVote
  int blueState = LOW , redState = LOW ;
  while(1) {
   blueState = digitalRead(BLUE_BUT);
   redState = digitalRead(RED_BUT);
   
  if(blueState == HIGH){
    Serial.println("BLUE");
    break;
    }
  
  if(redState == HIGH){
    Serial.println("RED");
    break;
    }
 
  
  }

Serial.println("PROGRAM COMPLETE");
}

(I cut the first part of the code, which I think is not neccessary to post because I don't think there is a problem with that part)

dannable:
Also posted on SE rfid - MFRC522 won't detect cards after the first loop - Arduino Stack Exchange

Which library are you using? I can't know since you didn't post the whole code(where is void setup?) which includes the header files.

cyberjupiter:
Which library are you using? I can't know since you didn't post the whole code(where is void setup?) which includes the header files.

I am using miguelbalboa's MFRC522 Library.

mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();

cyberjupiter:

mfrc522.PICC_HaltA();

mfrc522.PCD_StopCrypto1();

Thanks for your reply. But I have already tried adding these 2 lines (to the different parts of the code) but no luck with that.

Also posted on SE rfid - MFRC522 won't detect cards after the first loop - Arduino Stack Exchange

dannable:
Also posted on SE rfid - MFRC522 won't detect cards after the first loop - Arduino Stack Exchange

Yes, but aren't these separate communities ?

They are, but it may save people the effort of duplicating what advice has already been offered on other communities.

dannable:
They are, but it may save people the effort of duplicating what advice has already been offered on other communities.

Yes I get it, I am adding it to main post.

Take a few minutes to read the post at the top of each and every section: 'How to use this forum - please read'.

I have found out that it was something wrong with my jumper cables. Problem solved. Thanks for everyone.