2 mfrc522 in one arduino[SOLVED]

hi, I’m trying to use two rfid readers mfrc522 in the same arduino using spi, I’m sharing the MISO, MOSI and the SCK and giving each one its own SS and RST, but i cant get it to work, if I unplug one the other one works just fine but if I plug in both of them they won’t work even though it is the same code.
I’m using miguel balboa library.
here is the code, is the example included with the library but with some modifications.

#include <SPI.h>
#include <MFRC522.h>

#define RST_1_PIN         5 
#define RST_2_PIN         6// Configurable, see typical pin layout above
#define SS_1_PIN        11         // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
#define SS_2_PIN        12          // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1

#define NR_OF_READERS   2

byte ssPins[] = {SS_1_PIN, SS_2_PIN};
byte rstPins[] = {RST_1_PIN, RST_2_PIN};

MFRC522 mfrc522[NR_OF_READERS];   // Create MFRC522 instance.

/**
 * Initialize.
 */
void setup() {
  
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);
  Serial.begin(9600); // Initialize serial communications with the PC
  while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

  SPI.begin();        // Init SPI bus

  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    mfrc522[reader].PCD_Init(ssPins[reader], rstPins[reader]); // Init each MFRC522 card
    Serial.print(F("Reader "));
    Serial.print(reader);
    Serial.print(F(": "));
    mfrc522[reader].PCD_DumpVersionToSerial();
  }
}

/**
 * Main loop.
 */
void loop() {

  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    // Look for new cards

    if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
      Serial.print(F("Reader "));
      Serial.print(reader);
      // Show some details of the PICC (that is: the tag/card)
      Serial.print(F(": Card UID:"));
      dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
      Serial.println();
      Serial.print(F("PICC type: "));
      MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak);
      Serial.println(mfrc522[reader].PICC_GetTypeName(piccType));

      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC
  } //for(uint8_t reader
}

/**
 * Helper routine to dump a byte array as hex values to Serial.
 */
void dump_byte_array(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}

I’m using an arduino mega2560

#define SS_1_PIN        11         // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
#define SS_2_PIN        12          // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1

The key in that comment is UNUSED. When using SPI, 11 and 12 are NOT unused.

PaulS:
The key in that comment is UNUSED. When using SPI, 11 and 12 are NOT unused.

Forgot to mention it is a mega

Problem solved, just put an OR gate in the MISO so in case anyone else has this same problem, ther is the solution.

Captura.PNG