MP3 Interface for Arduino: Cheap and Easy

176K18440

Intro: 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);
  }

39 Comments

This is useful, not for the MP3 implementation rather just knowing how to simulate the button press in another device.

As for the MP3 player functions, I just uploaded my first instructable showing how to make a network controlled mp3 player using the ESP8266 and a serial controlled mp3 module. The whole thing cost less than $8, so that's truly inexpensive !

Check it out. https://www.instructables.com/id/WiFi-Enabled-MP3-P...

Dude, you just pressing buttons via cable, it's not cool. It will be if you made player from arduino itself (I have no idea is this possible or not but it's only one way to make it really cool, sry if I am wrong I'm not big specialist)

Now you can get these clip-on-better-than-an-ipod-shuffle-ipod-shuffle-clone for $1.50 on ebay!

Please help me suggesting that if mp3 player works by either applying to a constant 5v supply to the play/pause button or an impulse will work for the play button??

Awesome...

But.. is it possible to simultaneously read the contents of the sd card?

you Saved us from the greedy sound shield online suppliers (we all know them)...they sell MP3 shield with so little capability; flimzy sampling rate; many require file conversion...and as high as 30$..just to rip us...many thanks dresch..great hack indeed.

I have an Ipod Shuffle, one like on this link: http://img2.topproduct.nl/img/443467/483660-600-600-max-max/fellowes-powershred-ps-77cs-ipod-shuffle-1gb.jpg

how do you take one like that apart?
I have never touched an iPod shuffle (10X the value of these little MP3 players) but there is a YouTube video that might help you:
http://www.youtube.com/watch?v=67j1OebOsRI
was wondering if anyone had had any success doing the same thing with an actual iPod shuffle (I'm using the 3rd gen). Would love to hear!
Thank you. Another nicely detailed article.

Perhaps the schematic relating to the LC2093-B isn't accurate because one side of each button is connected to 3.3V and the other goes through a resistor and then Gnd, so if you shorted one side to ground you'd either bypass the resistor or just have both sides connected to Gnd. I guess that the resistors are in a different position relative to the switches in real life.

How did you work out which buttons needed to be shorted to Gnd and which needed to be connected via the analogue switches? On my MP3 player the buttons are connected differently to yours but I assume that the logic is the same. I just need to work out which ones I have to connect to ground and which to switch.
I have not looked at this in some time, but I thought the resistors were pull-ups and that the mechanical switches just shorted the pull-ups to ground when pressed. If you use the tri-state switch, then you don't need to use analog switches.
The tri-state uses only two output modes: 1) high-Z (impedance) like the mechanical switch is open and 2) zero or ground, like the mechanical switch is pressed, producing a short to ground.
Let me know if this is not right, but that is how I remember it.
The 2nd design does not use the analog switches at all.
Thank you for posting details of your project.

I'm considering replicating it using my Arduino Due but am wondering whether I need the analogue or tri-state switches. The Due uses 3.3V instead of 5V. Looking at the circuit diagram that you kindly attached in your follow-on article, it seems that the buttons on the MP3 player are part of a resistive touch input system; pressing different buttons connects different resistors which causes different voltage drops. I therefore do not understand your use of pin 8 on your Arduino board as surely that would mean bypassing the resistors and therefore the player not seeing different voltages for the different buttons.

BTW, I bought a similar player to yours. On opening it up it looks exactly the same at first and then I noticed small differences in the track layout. Checking the resistances between the butons I see that they are connected differently to yours. The main chip has a different number on it though I'd be very surprised if it had a different pin outlay.
You might want to look at the follow up article:
https://www.instructables.com/id/Cheap-and-Easy-MP3-Shield-for-Arduino/

Note that I use 3.3V for the circuit in that article which should be directly compatible with the Due. Note that I am shorting the switches on the MP3 player to ground, or leaving them floating, so I am not bypassing the pull up resistors. Good luck on your project!
I have an almost identical mp3 player, save for the sd card slot. I'd really like to try this project, but I'm having trouble finding exactly what TS5A3159 you bought on digikey. Also, a minor complaint, but none of the ic's listed were through-board. I suck at surface mount soldering, is there any version of this chip that isn't surface mount?

Help is greatly appreciated!
Hi,
I did a follow up using more standard logic (not the TS5a3159):

https://www.instructables.com/id/Cheap-and-Easy-MP3-Shield-for-Arduino/

The circuit in the above Instructable could be implemented using a standard Arduino proto shield with thru-hole logic. (I like surface mount because when I etch PCBs, then I don't have to drill holes. I can usually get away with single sided PCBs that way.)

Good Luck! Bill
I funded some really tiny arduino-compatibles thru Kickstarter; I have a few of those mp3 players and would like to put together a small package using the two together to upgrade the audio capabilites in my Wrangler.
I bought one of these from eBay before seeing this posting.

FYI.
The version that I received seems to use a different IC and operates from a 4.5V battery, instead of 3.3,

I've successfully run my version on 5V from an Arduino.

The Play / Pause, FWD and Back buttons seem to short the center pad of the button to GND (0V). The center's are all pulled high to about 3V (on a 5V supply)

To interface these buttons to the Arduino, the simplest solution seemed to connect a diode to each of these center connection, so that the Arduino could not drive 5V into the MP3 player, but when the Arduino output was LOW, it pulls the connection down to approx 0.5V (it can't get lower because the voltage drop across the diode).

I've tested this and it works fine, as long as the "button" is only pulsed low and not held low for a long time.
The low pulse needed to be more than 100 milli seconds. I tried 50 milli seconds and it didn't work. Higher values e.g. 250 milli seconds may work, but 100 milli seconds seemed to work reliably for me.

The Volume UP and Volume down however are more difficult to control.
These connections are directly linked to the FWD and BACK button (center connections)
And the outer connection on these buttons is not to GND (0V) and appears as 1.8k to GND, but when power is applied this connection has about 3V on it.

Looking at this on an oscilloscope, the voltage is not constant, but is pulses low for about 30 micro seconds every 15 milliseconds.

It would be possible to use some additional components to interface this to the Arduino. Possibly something as simple as a transistor may work.

It may also be possible to control the volume by connecting the outer connection of these buttons to an input on the Arduino.

Then in the Arduino code, when the connection goes low, the output would need to go low at the same time.
But this would probably need to be handled by an ISR, as the Arduino would need to send the output LOW very quickly for it to be registered by the MP3 player, and it may not be possible to do it this way at all, depending on the logic and timing inside the MP3 player.
Since my last posting, I've managed to get the volume controls to work as well.

I used a transistor BC109 with emitter to the outer of the button connection and collector to the inner connection. The base of the transistor was connected to the Arduino via a 1K resistor.

This seems to work and doesn't seem to effect the NEXT / BACK functionality which is on the shared connection with the Volume Up and Volume Down (2 pairs).

Also. BTW. The MP3 player was not bought from the same eBay store, and though it appears identical, the IC is different to the one in this article, and the connections are definitely not the same. However the ability to run on 5V is definitely a benefit.

However, one I have noticed a ticking noise on the audio output. I've tried adding extra capacitors to the supply and various other places on the board, but its not made any difference.
I'm not sure if this ticking is something to do with the specific audio tracks that I'm trying to play, as they may be too quiet, so I'll need to experiment with some louder track and also try different data rates etc, to see if this removes the problem


I forgot to mention. The IC on this MP3 player appears to be a GPD2101, however I've not found a data sheet for it yet.
More Comments