Fork me on GitHub

Project Notes

#500 RFID Concentration Game

Play a game of Concentration/Pairs with a stack of MIFARE Classic cards.

Build

Here’s a quick demo..

clip

Notes

You may have played Concentration - the simple card game where the objective is to pickup as many matching pairs of cards as possible.

I have a stack of RFID cards that I got with a reader, so attempting a version of Concentration was the first and most obvious thing that popped into my head!

Gameplay Design

I decided to keep the interaction as simple as possible, and in particular avoid the need for a text display unit, so I designed the game-play around:

  • an 8x8 matrix to display the card identity and flash various effects
  • a buzzer and LEDs for feedback
  • and the cards themselves for all input

Feedback states:

Name Buzzer Red Green Yellow Meaning..
gameRunning off off off Fast Flash in game mode, waiting for a card..
initializing off Flashing Flashing Flashing in card initialisation mode
CardInitialized Beep off ON Flashing card initialized, ready for a new one
CardInitializeFail Beep ON off Flash ON card initialize failed
cardAccepted Beep off Flashing off first card accepted, present another..
cardMatch Happy Beep off ON off second card match. Win!
cardMismatch Sad beep Flash ON off off second card mis-match. Fail!

The Doxygen documentation for the code is available here.

Additional libraries used in the Arduino code:

Setup

The RFID cards need to be initialized before they can be used.

After power-on:

  • if a recognised card is scanned, we assume you’re starting a game using the card set retrieved from EEPROM.
  • if an unrecognised card is scanned, we assume you’re setting up a new stack of cards:
    • the card set is initialised
    • the card is added to a new card set in memory (grouped into pairs), and the card ID is written back to the card
    • positive feedback (a “good” beep and green LED)
    • keeps initialising any other cards that are presented until max card limit reached, or an already-initialised card is presented (which triggers game mode)

Game Mode

  • after first card is presented, provides a neutral beep and red/green LEDs flash
  • when a second card is presented:
    • if it matches, plays a happy tune and green LED is on
    • if it does not match, plays a sad tune and red LED is on
  • game is over when all pairs have been successfully matched

Note:

  • it won’t bother to warn on repeated presentations of the same pairs - assume players are policing the rules themselves!
  • there’s no score-keeping, that’s up to players, as it doesn’t know who or how many players are in the game

Card Data

For simplicity, uses value blocks for a game ID and card ID.

Data is stored in sector 1. That is, block 4 to block 7:

  • block 4: the game ID value block
  • block 5: the card ID value block
  • block 6: unused
  • block 7: sector trailer

Each card is given a sequential number starting from 1. Pairs are the adjacent cards i.e. 1+2, 3+4 etc. That’s not random, as it assumes the players will use the age old technique of shuffling the cards before starting the game.

Circuit Design and Breadboard Prototype

Power: the MFRC522 is 3.3V device, and officially tolerant up to around 4V. So, running it with the 5V Uno is not strictly legit. Power is supplied correctly at 3.3V, but data lines will stray up to 5V. I haven’t included level shifters. But it does seem to work, as many have proven before, though I wouldn’t do it this way for anything requiring long term reliability.

Concentration_bb

Concentration_schematic

Concentration_bb_test

Final Build

Some decisions for the final build:

  • I replaced the 3 LEDs with the LEAP#269 Boldport Cordwood for the final build (because it’s purdy).
  • stuck with an Arduino Uno as the base board (as it has the 3.3V and 5V supply already taken care of)
  • still left out the level shifters for the MFRC522 data lines. So far, so good (fingers crossed)

The Boldport Cordwood gets some copper wiring so it can stand proud:

build_cordwood

Wiring and testing the modules before mounting:

build_wiring

I used some balsa wood with a clear varnish for the custom case. Mounting the modules:

build_mounting_modules

The final build in action:

Build

Credits and References

About LEAP#500 RFIDArduinoBoldportLED
Project Source on GitHub Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is my personal collection of electronics projects, usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.