Build it step by step
0 of 7 doneRead the tags
Print the UIDs.
Fill in the table
Pair number for each tag.
Add sounds
Four tracks on the card.
Write the game
First card, second card, match.
Add a win
After four pairs.
Make the cards
Pictures with the tag inside.
Build the reader box
Reader under a thin lid.
How do you build an RFID memory card game?
Children match pairs of picture cards with hidden RFID tags on a reader that says if they match. You need Arduino Nano, RC522 RFID reader, RFID tags 13.56 MHz (MIFARE Classic 1K) × 8, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, SanDisk microSD card 32 GB (A1, Class 10) and Resistor 1 kΩ. It takes 7 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 7
Parts list
- Development BoardsBuyArduino Nano × 1
- WirelessBuy
- WirelessBuy
- InterfacesBuy
- Motors & ActuatorsBuy
- SBC AccessoriesBuy
- PassivesBuyResistor 1 kΩ × 1
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| RFID SDA | Nano D10 | Chip select |
| RFID SCK, MOSI, MISO | Nano D13, D11, D12 | SPI |
| RFID RST | Nano D9 | Reset |
| RFID 3.3V and GND | Nano 3V3 and GND | Power |
| DFPlayer RX | Nano D3 through 1 kΩ | Sound |
| DFPlayer TX | Nano D2 | Status |
| DFPlayer speaker pins | 8 Ω speaker | Sound |
Code
Each card has an RFID tag taped inside and a picture on the outside; the reader hears a tag when it is held on the box top. First run the sketch and write down each tag's first UID byte from the Serial Monitor, then type them into the table, with a pair number for each; the first byte alone can repeat between tags, so for a real game use the whole four-byte UID. The MFRC522 runs at 3.3 V; most hobbyists connect it straight to a Nano, but it is safer to put a 1 kΩ and 2 kΩ divider on SCK, MOSI and SDA. Put four short sounds on the DFPlayer card: 0001 match, 0002 try again, 0003 first card and 0004 win. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails). Keep tags and loose parts away from very young children.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// RFID memory game: scan two cards, a match plays the happy sound. Libraries: MFRC522, DFRobotDFPlayerMini.
#include <SPI.h>
#include <MFRC522.h>
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
MFRC522 rfid(10, 9);
SoftwareSerial sw(2, 3);
DFRobotDFPlayerMini dfp;
// Run once and read the UIDs from the Serial Monitor, then type each tag's first byte and pair number here.
const byte UID_FIRST[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const byte PAIR_ID[8] = {1, 1, 2, 2, 3, 3, 4, 4};
int first = -1, turns = 0, found = 0;
int cardIndex() {
for (int i = 0; i < 8; i++) if (rfid.uid.uidByte[0] == UID_FIRST[i]) return i;
return -1;
}
void setup() {
Serial.begin(9600);
SPI.begin(); rfid.PCD_Init();
sw.begin(9600);
if (dfp.begin(sw)) dfp.volume(15);
}
void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;
Serial.print("UID first byte: "); Serial.println(rfid.uid.uidByte[0], HEX); // use this to fill in the table
int c = cardIndex();
rfid.PICC_HaltA();
if (c < 0) return;
if (first < 0) { first = c; dfp.play(3); delay(600); return; }
if (c == first) return;
turns++;
if (PAIR_ID[c] == PAIR_ID[first]) { found++; dfp.play(1); }
else dfp.play(2);
first = -1;
if (found == 4) { dfp.play(4); found = 0; turns = 0; }
delay(1000);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Scan a card | First-card sound |
| Scan its pair | Match sound |
| Scan a different one | Try-again sound |
| Four pairs found | Win sound and reset |
If it does not work
No card read
Hold it flat and closer to the reader.
Wrong matches
Use the full UID, not one byte.
No sound
Check the file names and the RX resistor.
Reader fails after a while
Check the 3.3 V supply.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the RFID memory card game?
Arduino Nano, RC522 RFID reader, RFID tags 13.56 MHz (MIFARE Classic 1K) × 8, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, SanDisk microSD card 32 GB (A1, Class 10) and Resistor 1 kΩ.
How long does the RFID memory card game take to build?
About 90 minutes for a beginner maker, in 7 steps.
How do I know the RFID memory card game works?
Scan a card: First-card sound. Scan its pair: Match sound. Scan a different one: Try-again sound.
No card read: what should I check?
Hold it flat and closer to the reader.
Wrong matches: what should I check?
Use the full UID, not one byte.
No sound: what should I check?
Check the file names and the RX resistor.
Reader fails after a while: what should I check?
Check the 3.3 V supply.
