loading
Picture of RFI-DJ: MP3 Playing RFID Thing
IMG_0375.JPG
IMG_0376.JPG
IMG_0385.JPG
The RFI-DJ is a USB device for playing MP3 files from your computer. You have a set of RFID cards, each one with a song name written on it. You choose a card and place it on the RFI-DJ, and your computer will play that song. Its magic!

Actually, it's not magic. It uses an Arduino and an ID-12 RFID scanner, and a python script running on your computer.

The device is really fun to use, and it makes a great afternoon project. The parts it uses are owned by most DIY people, and if you don't have them, they're pretty cheap and easy to find. The number of tracks it can play is severely limited to the number of RFID tags you have, so don't plan on throwing away your i-pod.

Wait a minute, I think I've seen this before...
Yes, unfortunately, you have. After starting on this instructable I discovered that somebody had already done something very similar, which can be found here. There are still many differences in his approach, such has that his is not USB, it is standalone, and his is much bigger and is more difficult and time-consuming to make. His is also based off of an i-pod.
Also, this project was inspired by this instructable. I probably wouldn't have thought of this without it. It's basically the same thing, but that one was with websites, not songs.

Here's a video I made of me playing a song with it (with my cat yelling in the background):



How it works:
An RFID scanner scans your card.
An Arduino processes the reading.
Based on the reading, the Arduino sends a letter to the serial port.
A python script reads the letter, and plays a song based on what letter it receives.
 
Remove these adsRemove these ads by Signing Up

Step 1: Supplies

Picture of Supplies
Here's what you need:
1 Arduino
1 RFID Reader
1 RFID Reader Breakout
Many RFID Tags
1 Computer
Some MP3 Files (Don't pirate them, please.)
Wire

Optional:
1 LED
1 Box of sorts (I used a cereal box)

Step 2: Download ALL THE THINGS!

You have a lot of things to download. Okay, just two, but it felt like a lot when I was downloading them. Here's the list, complete with installation instructions:

pySerial - A python module for serial communication.
It can be found here.
1. Download and extract.
2. Use "cd" to change your directory to the pyserial folder.
3. Use "sudo su" to change into root. (Use your root powers for good, not evil)
4. Run "python setup.py install" to install it and stuff.

mpg321 - A program to play MP3 files and such.
1. Run "sudo apt-get install mpg321" and type in the root password.
To test:
2. "cd" into the directory of an MP3 file.
3. Run "mpg321 [mp3filename].mp3" and it should be working.

Step 3: Wire up RFID Reader

Picture of Wire up RFID Reader
Solder the RFID reader to the breakout board. Then, wire as follows:
RFID reader pin 1 to ground.
RFID reader pin 2 to 5v.
RFID reader pin 11 to 5v.
RFID reader pin 10 to LED. (Optional: for debugging purposes. Will light up when a card is scanned.)
RFID reader pin 9 to Arduino pin 6.
RFID reader pin 7 to ground.

Done!

Step 4: Prepare Box (Optional)

Picture of Prepare Box (Optional)
You should now take the time to prepare your box. A standard cereal box works great when cut in half and wrapped in duct-tape. Then you should insert your Arduino and RFID reader. Trace an RFID tag over the reader on the box. Feel free to draw any artwork you want on the box.

Step 5: Figure Out RFID Identifiers

Run this code:

#include <SoftwareSerial.h>

SoftwareSerial RFID = SoftwareSerial(6, 7);

void setup ()

  Serial.begin(9600);
  RFID.begin(9600); //Begins connection with the reader
}
char read;
void loop ()
{
   while(RFID.available() > 0)
   {
      read = RFID.read();
      Serial.print(read);
   }
}

While that code is running, open up the serial monitor. Now, scan some cards, and write down the characters that show up in the serial monitor. Write letters (such as 'a' or 'b') on each card. Make sure each card has its own letter. On the same paper you wrote down the IDs, write down the letter associated with that ID.

Step 6: Arduino Code

Picture of Arduino Code
This is the BRAND NEW, SUPER AWESOME code that I used for my RFI-DJ, or it's at least more brand new, and more super awesome than when I first posted this instuctable. You must edit some lines to make it work for you.

#include <SoftwareSerial.h>

SoftwareSerial RFID = SoftwareSerial(6, 7); //RX is 6, TX is 7
String key; //The key that was scanned

void setup ()
{
  Serial.begin(9600);
  RFID.begin(9600); //Begins connection with the reader
}

char read; //The most recent character read

void loop ()
{
   while(RFID.available() > 0)
   {
      read = RFID.read();
      key += read;
      if(key.indexOf("4F0088AE355C") >= 0) {Serial.write('a'); key = "";} //Change to the ID of your key a
      if(key.indexOf("4F0088D4FCEF") >= 0) {Serial.write('b'); key = "";} //Change to the ID of your key b
      if(key.indexOf("4F0088FAFCC1") >= 0) {Serial.write('c'); key = "";} //Change to the ID of your key c
      if(key.indexOf("4F0088DA978A") >= 0) {Serial.write('d'); key = "";} //Change to the ID of your key d
      if(key.indexOf("4F0088F9E1DF") >= 0) {Serial.write('e'); key = "";} //Change to the ID of your key e
   }
}

Change the lines it says to change, and it'll work.



Step 7: Python Code

Picture of Python Code
Here is the python script that I used:

#!/usr/bin/python

import os
import serial
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=0) #First argument should be changed to your serial port, second should be your baudrate
while 1:
  x = ser.read() #Reads serial port
  if x == 'a':
    os.system("mpg321 come_together.mp3") #Change to your song a
  if x == 'b':
    os.system("mpg321 jumpin_jack_flash.mp3") #Change to your song b
  if x == 'c':
    os.system("mpg321 hey_jude.mp3") #Change to your song c
  if x == 'd':
    os.system("mpg321 my_generation.mp3") #Change to your song d
  if x == 'e':
    os.system("mpg321 stairway_to_heaven.mp3") #Change to your song e


Change that lines it says to change, and you'll be set.

Step 8: Playing Multiple Files At A Time

The python script shows how to play one song per card, but what if you want a certain card to play a full album? Or what if you want to play a certain playlist? The code can be easily changed to play a whole list of songs, and it is actually quite simple. First, you need to make a "list". Make a blank document and name it "playlist.lst". It could really be named anything ending in ".lst". In the file simply make a list of the songs you want to be on the playlist, such as:
asong.mp3
anothersong.mp3
yetanothersong.mp3


And that's all that needs to be in the file.
Change one of the os.system("mpg321 come_together.mp3") lines to:
os.system("mpg321 --list playlist.lst")
and it'll work now! The list can contain all the songs in an album, or all the songs by an artist, or it can even contain more lists!

Step 9: Use It!

Picture of Use It!
You have now finished making your RFI-DJ. To use it, you must do the following:
Label your cards with the song that they correspond with.
Plug the device into your computer.
Open up terminal, and change you directory to the directory of your python script. (Make sure that that's also the directory of your music)
Run "./rfi-dj.py"
Scan a card.
The song should instantly play!

If you have any questions, comments, or angry rants, feel free to post them in the comments section. I'll try to get back to you quickly.
Have fun and happy music-listening!
Ben10VenJay7 months ago

How can I install the mpg321? the "sudo" code is not working in cmd. Can you help me? Please :)

TomášM110 months ago
Or NFC tags and android
zajactom1 year ago

Hi,

I know it has been quite a time since this instructable was published, however since then I could not fine answer to my questions. I was thinking about making sort of music player by using only old laptop and one of those usb RDIF readers (they just like a keyboard but only passing the ID number). I was trying to avoid arduino and iPod and stuff. Just simple pc and usb RDIF. So far did not find anything that will not involve rocket science, as I am unfamiliar with any coding, servers etc. however I can follow some how to instructions. So my question is: does anyone knows about solutions or ideas how to turn old laptop and RFID usb reader into RFID music player?

klynas2 years ago
I would like to see this, but with a number pad next to it as well, so you could rfid your cd collection and still have a physical collection, but just swipe the cd case and press 'play all' or just a certain track.
alecnotalex (author)  klynas2 years ago
That would be very cool. If I have the time, I think I'll give it a try.
alex2015293 years ago
Is there a way to change the code so it plays a genre of music or a playlist? That would be really cool.
alecnotalex (author)  alex2015293 years ago
There, I finished. Look at step 8!
Wow Thanks! I am definitely going to make this now. Thanks again for the quick response
ilpug3 years ago
Nice idea, but I think it needs a better name... How about CardPlayer?
alecnotalex (author)  ilpug3 years ago
Maybe, but it's a little late to change the name.
Not really. You can edit the Instructable at any time.
alecnotalex (author)  ilpug3 years ago
Yeah, but it's current name is already written on a whole bunch of things, and is in a whole bunch of filenames and such. I just don't have the time to change that many things, due to being busy working on another project.
Makes sense.
Makes sense.
Great Project!
alecnotalex (author)  AmbrosiaElixir3 years ago
Thank you!
ElectroFlex3 years ago
When you remove the ID Tag, does the music pause?
alecnotalex (author)  ElectroFlex3 years ago
No, it does not. So, you really just need to swipe the card and it'll work.