include <spi.h>
include <mfrc522.h>
include “Arduino.h”
include “SoftwareSerial.h”
unsigned char order[4] = {0xAA,0x06,0x00,0xB0};
define SS_PIN 10
define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
SoftwareSerial Serial1(7, 6); // RX, TX
//============SETUP================
void setup()
{
Serial1.begin(9600);
volume(0x1E);//Volume settings 0x00-0x1E
Serial.begin(115200); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println(“Approximate your card to the reader…”);
Serial.println();
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print(“UID tag :”);
String content= “”;
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? “ 0” : “ “);
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? “ 0” : “ “));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print(“Message : “);
content.toUpperCase();
if (content.substring(1) == “69 E4 3C A3”) //change here the UID of the card/cards that you want to give access
{
Serial.println(“Authorized access”);
Serial.println();
play(0x01);//Specify playback: 0x01-file 0001
delay(1000);
}
if (content.substring(1) == “67 33 7E 7A”) //change here the UID of the card/cards that you want to give access
{
Serial.println(“Authorized access”);
Serial.println();
play(0x02);//Specify playback: 0x02-file 0002
delay(1000);
}
if (content.substring(1) == “D7 3F 7C 7B”) //change here the UID of the card/cards that you want to give access
{
Serial.println(“Authorized access”);
Serial.println();
play(0x03);//Specify playback: 0x03-file 0003
delay(1000);
}
if (content.substring(1) == “F7 E6 51 7B”) //change here the UID of the card/cards that you want to give access
{
Serial.println(“Authorized access”);
Serial.println();
play(0x04);//Specify playback: 0x04-file 0004
delay(1000);
}
if (content.substring(1) == “E7 B6 72 7B”) //change here the UID of the card/cards that you want to give access
{
Serial.println(“Authorized access”);
Serial.println();
play(0x05);//Specify playback: 0x05-file 0005
delay(1000);
}
if (content.substring(1) == “37 18 84 7B”) //change here the UID of the card/cards that you want to give access
{
Serial.println(“Authorized access”);
Serial.println();
play(0x06);//Specify playback: 0x06-file 0006
delay(1000);
}
if (content.substring(1) == “87 2E 79 7A”) //change here the UID of the card/cards that you want to give access
{
Serial.println(“Authorized access”);
Serial.println();
play(0x07);//Specify playback: 0x07-file 0007
delay(1000);
}
else {
Serial.println(“ Access denied”);
delay(1000);
}
}
//==========FUNCTION==========
void play(unsigned char Track)
{
unsigned char play[6] = {0xAA,0x07,0x02,0x00,Track,Track+0xB3};//0xB3=0xAA+0x07+0x02+0x00,that is, the last digit is the checksum
Serial1.write(play,6);
}
void volume( unsigned char vol)
{
unsigned char volume[5] = {0xAA,0x13,0x01,vol,vol+0xBE};//0xBE=0xAA+0x13+0x01,that is, the last digit is the checksum
Serial1.write(volume,5);
}
```</mfrc522.h></spi.h>