RFID ID Displayer: 36 Lines to Read a Card and Nothing More
Before you can build an RFID lock, you need to know your card's ID. That is the entire purpose of this project. No servo. No comparison. No access control. Just the MFRC522 reader, the Arduino, and the serial monitor.
The code calls PICC_IsNewCardPresent and PICC_ReadCardSerial to read the UID from any card brought near the reader. It formats the bytes as a hexadecimal string and prints it to the serial monitor. Then it halts communication and waits for the next card.
What It Does
The loop is simple. Detect a card. Read its UID. Convert each byte to hex. Concatenate them. Print the result. Stop communicating with that card so it can be read again later.
There is no comparison logic. No authorized list. No action triggered by a match. The output is raw card data intended for a human to read and copy into another program. The RFID Door Lock project uses this exact approach but adds the comparison and servo steps.
What I Would Change
The code builds the UID string using Arduino String objects inside the loop. On a microcontroller with limited RAM, repeated allocation fragments memory. A fixed character array with sprintf would be more reliable for long running use.
There is no rate limiting. If a card stays within range, the loop reads it repeatedly and prints the same ID over and over. A debounce flag or a cooldown period would prevent serial spam.
The pin definitions are hardcoded. Changing the wiring means editing the sketch. That is fine for a one-off project but makes sharing or reusing the code harder.
It is 36 lines and it does one thing. Tap a card. Get an ID. That is the minimum viable step before anything useful can happen. Every RFID project I built later started here.