Introduction: MP3 Interface for Arduino: Cheap and Easy

I have added a follow-on to this Instructable:
https://www.instructables.com/id/Cheap-and-Easy-MP3-Shield-for-Arduino/
The follow-on shows you how to design, etch and build a PCB shield to connect the MP3 to the Arduino. Replaces the analog switches with a 74HC244. SIngle layer board with large surface mount component design. Only 5 thru holes. Take a look.

Ebay abounds with sales for REALLY inexpensive MP3 "Clip" players. These players support MicroSD cards up to 8G, have a built in headphone amp, have built in volume control and Next and Previous control for stepping thru MP3 files. The Clip Players have their own battery and a mini USB port for battery charging and file exchange with the MicroSD card. (You have to supply your own MicroSD card.) And considering the low price, the sound quality is quite good.

For instance:
http://www.ebay.com/itm/ws/eBayISAPI.dll?ViewItem&item=330654403698&ssPageName=ADME:L:OU:US:1123
I had originally bought mine for $5, now up to $6.75! Better buy a few now...

If you need to add a little music or voice to your next Arduino project, this simple hack will get you there. So here is how this works. We remove the guts to one of these inexpensive little MP3 players, solder on a couple of wires to the MP3 circuit board and attach then two an Arduino protoshield (if you are using a full size Arduino, I will show wiring to an Arduino Mini also.) The circuit also requires two analog switches to completely control all the front panel buttons. The Arduino code to control the MP3 player is really simple and an example is provided. You load your sound files on to a MicroSd card and name them in a way so that they can be sequenced in the way you want. When you are done, your Arduino will be able to step to and play specific sound files, adjust volume up or down, pause, etc.

I plan on following up with an EagleCad shield design. But for right now, its wires and solder and a little programming, so Arduinites can get going.

And of course, after I wrote this, I found this one also:
https://www.instructables.com/id/Adding-MP3-to-your-project-for-300/
Hopefully whatever I have left out, you can find in the above.

Step 1: Disassembly of the MP3 Player

These little guys are so cute and functional, it was hard to bring myself to open it up, but honestly, if I didn't do it...
So, first get a really small jeweler's Philips head screwdriver and remove the two screw on the white plastic side panel. The panel will pop off when the screws are off. (A small flat blade in the microsd slot. Be gentle!)
With the side off, you will be able to push out the other side. It is U-shaped.
With the other side out, you will be able to push out the PCB and battery. Again, be slow and gentle.

Now everything is out. Cool! Lets take a look at the circuit.

Step 2: Looking at the MP3 Player Internals

The PCB holds a power switch, stereo headphone jack, a 32kHz crystal, a MicroSD card socket and a mystery IC (at least for me). There is also a 3.5V (?) Li-Poly (?) battery. I don't use the battery in this design... but don't let me stop you.

The IC is an LC2093-B. Here is what I found on the web:

LC2093-B
AB1145D2G003

www.sztgmic.com

MP3 Decoder IC

MP3 decoder board supports FM program features ....
1 Personal Emergency Link ( USB-AUDIO sound card) function,
just use mini- USB cable to connect between the computer,
cool dog can identify 'MP3 simply repeating listen to '
direct control of key PC down selections / volume;
2 download (reader) function : Connect PC can act as a reader,
free copy of the SD card / TF card contents;
3.SD/TF / card playing / U disk playback MP3, 24bit DAC ,
the sound lifelike detail , S / N: 92dB , almost hear the noise
4 support FM , Bluetooth, Iphone
5. directly promote the headphone
output by nearly 3V
6. two line in input, Switch no popo sound
7.ADKEY hardware random selection button function
8. low BOM cost, built-in real RTC function , can save 24C02 memory IC ,
integrated IR decoding, instead of using infrared diode infrared receiver,
built- MUTE circuits, no external transistor , the master part only
10 external components than
9 built-in crystal compensation,
the use of very wide use of cheap 32.768KHZ crystal
10.SSOP 24 package processing cost is low

If anyone can locate a datasheet and post it, I would be very appreciative...

Step 3: Getting Control...

We are going to control the MP3 player thru the 5 key PCB pad (rings and bulls-eyes). We  will need to make 3 solder connections to the key pad area. We also need to make a ground connection and a 3.3V power connection.

First, a little explanation of how the keypad is wired on the PCB. Take a look at the Connections photo. There are 4 unique connections between the rings and bulls-eyes. But one of the connections is ground based, so we don't have to attach a wire for that connection. The ground based connection allows control of the PLAY/PAUSE, VOL+ and VOL- control. This is simple, we just use three of the Arduino's IO pins to ground the bulls-eyes for these three signals. SInce the MP3 player is running at 3.3V and the Arduino is running at 5V, we simply make these 3 pins INPUTS until we need to ground one of them. Then we make them a LOW OUTPUT. No excessive voltage is ever applied to the MP3 signal lines.

The purple, orange and red dots are where you want to solder some wires (I used wire wrap wire.) I connected VOL+ (purple) to Arduino pin 10, VOL- (red) to Arduino pin 9 and PREV (orange) to Arduino pin 8.

To make connections purple and orange (PREVious) and red and orange (NEXT), you will need TWO tri-state buffers or TWO analog switches. Luckily I had some analog switches from a previous project. (There are probably more clever ways of making these connections but there are some subtle problems to overcome.)

Step 4: Lovely Analog Switches

The Texas Instruments TS5A3159 is a lovely little chip. It is a SPDT in a SOT23-6 package with about 1 ohm of ON resistance. It is available thru DigiKey. I had an old board I could modify to hold these two TS5A3159's
.
I know this won't be everyone's situation... you should be able to use a standard tristate driver (like 74HC244 or 74HC245) in a DIP package to do the same thing. I will post an update when I have had a chance to test this.

I am including a schematic of how the switches are wired to the Arduino shield (7 connection points). When either of these switches are turned on, they short NEXT to VOL- or PREV to VOL+. The player then steps forward or backward thru the MP3 list on the MicroSD card.

The stepping process is not at microprocessor speeds, but at human-finger-press speeds, like tenths of seconds.

If you name your MP3 files: 001.MP3, 002.MP3, 003.MP3, 004.MP3, etc. then there is no confusion of the order the files will be played.

Step 5: Getting the System Ready to Test

To test this system you will need to add four MP3 files to the MicroSD card named as previously described (0001.MP3, 002.MP3...) Insert the MicroSD card,
Plug an earphone or headphone into the jack.
Plug in a USB cable into the Arduino and the USB port on your favorite computer. After a few seconds the first file will begin playing. If you load the attached Arduino sketch into the Arduino enviroment on your computer and download it, you will here 10 second clips of each file, with the volume decreasinng after the first four song snippets are played, and then the volume increasing after the next four.

Note the delay lengths I used for the specific controls. You may be able to shorten these times... experiment!

Here is the sketch to cut and paste into the Arduino enviroment:

int CTL_NEXT = 6;
int CTL_PREV = 7;
int PLAY = 8;
int VOL_MINUS = 9;  
int VOL_PLUS = 10;  

int LLED = 13;
int i,j; //the loop counter
/*
void nextMP3(void){
PORTB = 0x00;
DDRB = 0;
DDRD = 0x40;
  while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//1
  while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//2
   while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//3
  while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//4
   while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//5
  while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//6
   while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//7
  while ((PINB & 0x01)!=0)
  PORTD = 0x40;
  while ((PINB & 0x01)==0)
  PORTD = 0;//8 
  DDRD = 0;//PORTD an input again
}

void prevMP3(void){

PORTB = 0x00;
DDRB = 0;
DDRD = 0xA0;
  while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//1
  while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//2
    while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//3
  while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//4
    while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//5
  while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//6
    while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//7
  while ((PINB & 0x01)!=0)
  PORTD = 0x80;
  while ((PINB & 0x01)==0)
  PORTD = 0;//8
  DDRD = 0;//PORTD an input again

}*/

void nextMP3(void){
digitalWrite (CTL_NEXT, HIGH);
delay(100);
digitalWrite (CTL_NEXT, LOW); 
}

void prevMP3(void){
digitalWrite (CTL_PREV, HIGH);
delay(100);
digitalWrite (CTL_PREV, LOW);
}

void FlashDatLED(void){
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100);
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100);
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100);
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100);
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100);
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100);
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100);
    digitalWrite(LLED,HIGH);
    delay(100);
    digitalWrite(LLED,LOW);
    delay(100); 
}

// The setup() method runs once, when the sketch starts

void setup(void)   {               


  // initialize the digital pin as an output:
  pinMode(PLAY, INPUT);
  digitalWrite (PLAY, LOW); //Turn OFF the pull-up
  pinMode(VOL_MINUS, INPUT);
  digitalWrite (VOL_MINUS, LOW); //Turn OFF the pull-up 
  pinMode(VOL_PLUS, INPUT);
  digitalWrite (VOL_PLUS, LOW); //Turn OFF the pull-up
  pinMode(CTL_PREV, OUTPUT);
  digitalWrite (CTL_PREV, LOW); //BOTH SWITCHES OPEN
  pinMode(CTL_NEXT, OUTPUT);
  digitalWrite (CTL_NEXT, LOW); //BOTH SWITCHES OPEN
  pinMode(LLED,OUTPUT);

//ALL ARE WEAKLY PULLED HIGH
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                    
{


delay(2000);
//while(1);


  while (1){
    digitalWrite(LLED,HIGH);
    prevMP3();
     pinMode(LLED,OUTPUT);
    digitalWrite(LLED,HIGH);
    delay(10000);
    digitalWrite(LLED,LOW);
    prevMP3();
    delay(10000);

    prevMP3();
    pinMode(LLED,OUTPUT);
    digitalWrite(LLED,HIGH);
    delay(10000);
    digitalWrite(LLED,LOW);
    prevMP3();
    pinMode(VOL_MINUS, OUTPUT);
    delay(2000);
    pinMode(VOL_MINUS, INPUT);
    delay(8000);

    digitalWrite(LLED,HIGH);
    nextMP3();
     pinMode(LLED,OUTPUT);
    digitalWrite(LLED,HIGH);
    delay(10000);
    digitalWrite(LLED,LOW);
    nextMP3();
    delay(10000);

    nextMP3();
    pinMode(LLED,OUTPUT);
    digitalWrite(LLED,HIGH);
    delay(10000);
    digitalWrite(LLED,LOW);
    nextMP3();
    pinMode(VOL_PLUS, OUTPUT);
    delay(2000);
    pinMode(VOL_PLUS, INPUT);
    delay(8000);
  }

Arduino Challenge

Participated in the
Arduino Challenge