Recently, I am doing a project which is using the RFID-RC522 and Arduino to obtain the UID of a card. Then, I wish to use the UID to do a matching between different soundtracks on PC so that it will respond me with a specific track.
From this stage, I have already found the way to obtain UID, but I have found that there were no method for me to play music on PC if I am using Arduino IDE.
Here is the code I altered from MFRC522 library's Dumpinfo,
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 5 // Configurable, see typical pin layout above
#define SS_PIN 10 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
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
mfrc522.PCD_Init(); // Init MFRC522
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Dump debug info about the card. PICC_HaltA() is automatically called.
//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
//Serial.println(&(mfrc522.uid));
Serial.print(F("Card UID:"));
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
delay(5000);
}