Problem creating function to read RFID and using MUX

hello I’m trying to adapt the example code from “https://www.arduinoall.net/arduino-tutor/code/rfid_buzzer.rar

and in the example look like this

#include <SPI.h>
#include <RFID.h>

#define SS_PIN 10
#define RST_PIN 9

RFID rfid(SS_PIN, RST_PIN);

// Setup variables:
int serNum0;
int serNum1;
int serNum2;
int serNum3;
int serNum4;

void setup()
{
Serial.begin(9600);
SPI.begin();
rfid.init();

}

void loop()
{

if (rfid.isCard()) {
if (rfid.readCardSerial()) {
if (rfid.serNum[0] != serNum0
&& rfid.serNum[1] != serNum1
&& rfid.serNum[2] != serNum2
&& rfid.serNum[3] != serNum3
&& rfid.serNum[4] != serNum4
) {
/* With a new cardnumber, show it. */
Serial.println(" ");
Serial.println(“Card found”);
serNum0 = rfid.serNum[0];
serNum1 = rfid.serNum[1];
serNum2 = rfid.serNum[2];
serNum3 = rfid.serNum[3];
serNum4 = rfid.serNum[4];

//Serial.println(" ");
Serial.println(“Cardnumber:”);
Serial.print("Dec: “);
Serial.print(rfid.serNum[0],DEC);
Serial.print(”, “);
Serial.print(rfid.serNum[1],DEC);
Serial.print(”, “);
Serial.print(rfid.serNum[2],DEC);
Serial.print(”, “);
Serial.print(rfid.serNum[3],DEC);
Serial.print(”, “);
Serial.print(rfid.serNum[4],DEC);
Serial.println(” ");

Serial.print(“Hex: “);
Serial.print(rfid.serNum[0],HEX);
Serial.print(”, “);
Serial.print(rfid.serNum[1],HEX);
Serial.print(”, “);
Serial.print(rfid.serNum[2],HEX);
Serial.print(”, “);
Serial.print(rfid.serNum[3],HEX);
Serial.print(”, “);
Serial.print(rfid.serNum[4],HEX);
Serial.println(” “);
} else {
/* If we have the same ID, just write a dot. */
Serial.print(”.”);
}
}
}

rfid.halt();
}

I’m trying to move the code inside loop to create a function and call the function instead but it doesn’t work

the other problems is I’m using 16-channels MUX to control 16 RFID and it doesn’t work too. Even I put the reading code inside loop

it doesn't work

Please post what you tried, but look at this topic first Read this before posting a programming question then post your code and description of the problem and error messages as it advises

In the photo it’s shown the code in the RFID’s library that when read and show the ID of key tag. but what I’m going to do is store the ID inside a variable instead

Screen Shot 2563-01-08 at 09.18.04.png

What must we do with a screenshot of code?

Read the link that UKHeliBob posted (again?), specifically where it mentions [code]...[/code].