RFID inputs string based on the cards UID

Hello everyone,
I’m trying to set a string based on the cards UID, so basically if card “A” (card “A” UID “30 75 7E 7A”) is close to a reader it types the string and if card “B” is close it types different string. But I can’t figure out how to implement Keyboard.print into this.
I’m using leonardo and a cheap RFID RC522 from aliexpress

Here is the code i used

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

#define RST_PIN         9          // Configurable, see typical pin layout above
#define SS_1_PIN        10         // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
#define SS_2_PIN        8          // 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};

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

/**
 * Initialize.
 */
void setup() {

  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], RST_PIN); // Init each MFRC522 card

  }
}

/**
 * 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()) {
      // Show some details of the PICC (that is: the tag/card)
      dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
      Serial.println();
      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC

[b]if (mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size = "30 75 7E 7A"){
Keyboard.print("some random string");
    } [/b]
  }
  //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);
  }
}

Your problem is probably in the way you are trying to check for a UID match:

if (mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size = "30 75 7E 7A")
  1. uid.uidByte is NOT a text string
  2. That is not how you compare two text strings. You would use strncmp().

You should probably compress the four bytes of binary into an unsigned long and then compare with a set of unsigned long hex constants:

 unsigned long UID_unsigned;
 UID_unsigned = mfrc522.uid.uidByte[0] << 24;
 UID_unsigned += mfrc522.uid.uidByte[1] << 16;
 UID_unsigned += mfrc522.uid.uidByte[2] << 8;
 UID_unsigned += mfrc522.uid.uidByte[3];
 switch (UID_unsigned) {
    case 0x30757E7AUL:  // Card A
        do stuff for Card A;
        break;

    case [some other value]: // Card B
        do stuff for Card B;
        break;

    default:   Serial.print(F("Unrecognized Card:  0x"));
        Serial.println(UID_unsigned, HEX);
        break;
    }

2) That is not how you compare two text strings. You would use strncmp().

Since the array is not a text string, strncmp() is not appropriate. memcmp() is.