Comments: Getting Started with the LilyPad MP3 Player

Pages

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • -------------------- Tech Support Tips/Troubleshooting/Common Issues --------------------

    Arduino Resetting when Playing Track

    The FTDI is not able to source enough power through a computer’s COM port. The amplifier, audio decoder chip, and the microcontroller is pulling more current than your computer’s COM port can provide, resulting in the LilyPad MP3 resetting or cutting out when playing through the tracks. Works fine after connecting a LiPo battery to the board’s JST connector. I had this same issue the other day with a personal project.

    There are alternatives listed in the hookup guide => https://learn.sparkfun.com/tutorials/getting-started-with-the-lilypad-mp3-player#hardware-details-and-hacking-tips .

    FTDI

    Make sure that you use a 5V LilyPad FTDI or the 5V FTDI Basic Breakout. There is a resistor on the Rx line that can cause issues uploading to the microcontroller if you were using the FT231X breakout. This FTDI is 3.3V. While the IC can be used on a RedBoard, the microcontroller can recognize the 3.3V logic high. With the LilyPad MP3, the resistor might bring the logic high lower than its acceptable value just enough to not be able to upload any code.

    There was one case where a customer used a 5V Vcc - 3.3V I/O FTDI and had issues uploading. After removing R21, they were able to upload code. In the end, it might be good to just get a dedicated 5V FTDI for the LilyPad MP3.

    Issues with WAV Playback?

    Your tracks are configured correctly under the Supported Audio Formats https://learn.sparkfun.com/tutorials/getting-started-with-the-lilypad-mp3-player/supported-audio-formats. I tested the same setup and files from Audacity but I was unsuccessful with the files too. There does not seem to be any meta-data. Setting the stereo .wav track with "signed 16-bit PCM" at 8000Hz, I was able to hear the track better but the quality of the sound was significantly lower than an MP3 track being played. =(

    Quick Fix

    As a quick fix, they can change the configuration of the .wav files so that it can be played with the LilyPad MP3 Player. I do remember another engineer had somehow got it working so I tested out the .wav files from this tutorial => https://learn.sparkfun.com/tutorials/sound-page-guide#hacking-your-kit . I was able to get those .wav files working from the tutorial. It looks like he reduced the file size to mono and 22050 Hz for the project rate in Audacity. Testing this on a customer's .wav files exported as a "signed 16-bit PCM", I was able to get a clearer sound. Try modifying the .wav files with that configuration. The issue is that the rate is reduced and the audio track has been converted from stereo to mono. I'm not exactly sure why 32000 Hz and 44100 Hz rates with stereo and .wav files as signed 16-bit PCM do not work. Maybe the VS1053B cannot handle the quality of the wav files and the datasheet is wrong?

    Arduino Error

    If you see this error specifically, you selected the wrong AVR microcontroller for the board definition:

    Arduino: 1.6.4 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega168 (3.3V, 8 MHz)"
    
    Build options changed, rebuilding all
    
    Sketch uses 15,708 bytes (109%) of program storage space. Maximum is 14,336 bytes.
    
    Global variables use 996 bytes (97%) of dynamic memory, leaving 28 bytes for local variables. Maximum is 1,024 bytes.
    
    processing.app.debug.RunnerException: Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
    .
    .
    .
    
    Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
    

    Make sure that you are selecting “Arduino Pro or Pro Mini (3.3V/8MHz) w/ ATmega 328,” or you won’t be able to compile and upload to the LilyPad MP3 Player’s microcontroller.

    Increasing the Number of Trigger Pins

    If you are trying to increase the number of trigger pins on the LilyPad MP3 Trigger without adding additional parts to the project (like using a multiplexor, adding another Arduino microcontroller, etc.), you could redefine some of the pins connected to the rotary encoder header. This is assuming that you are not using a rotary encoder with the board. This is briefly described in "Hardware Details and Hacking Tips: Even more headers" [ https://learn.sparkfun.com/tutorials/getting-started-with-the-lilypad-mp3-player/hardware-details-and-hacking-tips ]. You can potentially have 5x additional triggers by soldering wires to the pinouts that are connected to LEDB (D5), LEDG (A1), LEDR (D10), ROT-B (A3), ROT-A (D3). The button pin (D4), did not seem to work because it is already grounded via a 1kOhm resistor. If you cut the trace leading the pin to ground, you can potentially have an additional trigger pin.

    For example, if you wanted to use a trigger to digital pin 5 (LEDB), you would need to adjust 6 lines of the Trigger.ino code in order to get it working with pin 5. You would need to define additional pins, increase the trigger[] array, increase the number of file names, adjust the pin in the for() loop to setup the trigger input pins, change the condition that looks for a number associated with the track, and change the check to read the trigger's pin state:

    ----------------------------------------------------------------------------------------------------

    1.) Defining Another Trigger Pin

    After line 64 were it says:

    const int TRIG5 = 0;
    int trigger[5] = {TRIG1,TRIG2,TRIG3,TRIG4,TRIG5};
    

    define an additional trigger pin like so:

    const int TRIG5 = 0;
    const int TRIG6 = 0;          //add additional trigger pin
    int trigger[5] = {TRIG1,TRIG2,TRIG3,TRIG4,TRIG5};
    

    2.) Increase the Trigger Array

    After adding an additional driver pin, adjust the trigger[] array to accommodate the additional trigger which should now be located on line 66 from:

    const int TRIG5 = 0;
    const int TRIG6 = 0;           //add additional trigger pin
    int trigger[5] = {TRIG1,TRIG2,TRIG3,TRIG4,TRIG5};
    

    to:

    const int TRIG5 = 0;
    const int TRIG6 = 0;
    int trigger[6] = {TRIG1,TRIG2,TRIG3,TRIG4,TRIG5,TRIG6}; //adjust array size and add trigger pin in the array
    

    3.) Increasing the Number of File Names

    Adjust the filename[][] array on line 104 from:

    char filename[5][13];
    

    to:

    char filename[6][13];          //adding additional array for TRIG6
    

    4.) Adjust the Pin in the for() Loop to Setup the Trigger Input Pins

    Change the limit in the for() loop to setup the number of triggers on line 17 from:

     for (x = 0; x <= 4; x++)
    

    to:

    for (x = 0; x <= 5; x++) //add additional trigger pin by increasing the limit to 5
    

    5.) Change the Condition that Looks for a Number Associated w/ the Track

    Adjust line 198 where the condition statement looks for the the number associated with the file name from:

    if (tempfilename[0] >= '1' && tempfilename[0] <= '5')
    

    to:

    if (tempfilename[0] >= '1' && tempfilename[0] <= '6') //look for files with the numbers 1-6
    

    6.) Change the Check to Read the Trigger's Pin State

    On line 265, you would change the number of triggers that you are checking from:

    for(t = 1; t <= (debugging ? 3 : 5); t++)
    

    to

    for(t = 1; t <= (debugging ? 3 : 6); t++) //check the state of the trigger pins between triggers 1-6.
    

    ----------------------------------------------------------------------------------------------------

    For more trigger pins, just repeat the steps outlined above for additional trigger pins. Remember, the audio tracks wound need to have the same number associated with the file name.

  • Member #961308 / about 6 years ago / 1

    Just wondering if the Lilypad MP3 board is washable like other Lilypads?

    • MikeGrusin / about 6 years ago / 1

      It is washable! Like all LilyPads; remove the battery first, hand-wash, and let it thoroughly dry (for at least a few days).

  • Member #961308 / about 6 years ago * / 1

    In the User Guide, it says the LilyPad MP3 "is capable of driving about a watt of power into each channel." I've been using 3" Diameter - 8 Ohm 1 Watt Speakers from Adafruit and they've worked well. (https://www.adafruit.com/product/1313)

    They are currently out of stock so I'm wondering if I can use the 3" Diameter - 4 Ohm 3 Watt speaker instead? (https://www.adafruit.com/product/1314)

    Thanks! Rachel

    • MikeGrusin / about 6 years ago / 1

      Hi Rachel, you certainly can. They may run slightly quieter than the 8 ohm speakers, but if you turn up your volume a bit they should work well.

  • Brice P / about 7 years ago / 1

    Do you know if there's a way with this hardware to know when the LiPo battery is going to need to be charged? I have a power/status led connected to one of the pins, and I'd like it to blink when the battery needs to be charged again (If there is a solution by separating power and status, making two leds instead, it's also ok for me).

    Is it something the software already has access to? Or is it doable by connecting the LiPo+ to an analogic input pin? I'd rather not add any extra parts as the Lilypad already contains every I need...

    Also, can you confirm that the charging circuit will detect when the battery is fully charged so leaving the charger connected for longer periods of time (some days for example) won't harm the battery?

    Thanks! Brice

    • MikeGrusin / about 7 years ago / 1

      Brice - To answer your second question, the charger will definitely stop when the battery is full; you can leave the charger connected indefinitely and it won't overcharge the battery.

      As far as reading the battery voltage goes, your idea to connect it to an analog input like T1 (A0) is a good one. One problem is that a full battery is 4.2V, and analog inputs can only be as high as the system voltage (3.3V). However, you can run the battery through a voltage divider consisting of two 10K resistors before connecting it to the analog input. This will divide the battery voltage in half, so a full battery will only appear as 2.1V, which can be successfully read as an analog input (just multiply it by two to get the real result). Hope this helps, good luck with your project!

      • Brice P / about 7 years ago / 1

        Hi again, I'm having two issues with the board: - I tried to connect the same speaker to both outputs, in parallel, (I just need a mono output, but I'd like if possible to have twice the power. But once I connect it this way, I just have no sound at all. I wished the outputs' power would be summed, but no. Do you know if I could benefit from 2×1.5W (@4ohms) on a single speaker without too much extra hardware? - I randomly have the microsd card failing at startup. I tried the solution I found here but it didn't help. The only microsd card I have might be a bit old. Do you believe a new class 6 or 10 would solve the issue? In that thread, it appears to be the loading time of the card that causes the problem. About your previous answers, knowing that it won't harm the battery to leave it plugged in, I won't need to manage a charging led. When they don't use the system, they'll just plug it in and keep it that way. Thanks for spreading your knowledge here, it is of great help!

        • Brice P / about 7 years ago / 1

          Using a new class 10 microsd card, I now no longer have the booting issue. The other question regarding the stereo-to-mono-to-sum-the-powers problem remain. If anyone has any idea about it, I'd like to hear it! Thanks

          • MikeGrusin / about 7 years ago / 1

            I believe that the outputs from this particular type of amplifer (class D) can't be summed. This type of amplifier outputs a PWM-like signal that is alternately connected to power or ground. If you sum them you'll periodically create a short from power to ground which the chip is likely protecting against and going silent. Plus since power and ground are "full power" anyway, you don't gain anything by summing the outputs. We do have a self-amplified "hamburger" speaker that may help.

            • Brice P / about 7 years ago / 1

              Thanks for the explanations and for the idea! I don't think that will do it on this project, as the speaker and the module will no be physically accessible, so we can only rely on switching on and off the main board by switching the power on and off, and everything else has to work programmatically. But if the signal is PWM, wouldn't it be possible to add a simple transistor to the sound output to have the maximum number of watts available on the speaker? (I probably got it wrong though, tell me if it's the case!). I don't need quality for the output (no music, no voice, just environmental sounds like car engines).

      • Brice P / about 7 years ago / 1

        Thanks Mike! Sorry I didn't answer before, I've been taken on other projects.

  • Member #667671 / about 8 years ago / 1

    What the limitations on the size of the sd card?

    • MikeGrusin / about 8 years ago / 1

      The last time I checked, the sdfat library that the example software uses could handle cards up to 32GB.

  • Member #514055 / about 8 years ago / 1

    Anyone else have issues with WAV playback? Here's my write-up on this board so far:

    http://www.jeremydeprisco.com/lilypad-mp3-player/

    • Your tracks are configured correctly under the Supported Audio Formats https://learn.sparkfun.com/tutorials/getting-started-with-the-lilypad-mp3-player/supported-audio-formats. I tested the same setup and files from Audacity but I was unsuccessful with the files too. There does not seem to be any meta-data. Setting the stereo .wav track with "signed 16-bit PCM" at 8000Hz, I was able to hear the track better but the quality of the sound was significantly lower than an MP3 track being played. =(

      Quick Fix

      As a quick fix, they can change the configuration of the .wav files so that it can be played with the LilyPad MP3 Player. I do remember another engineer had somehow got it working so I tested out the .wav files from this tutorial => https://learn.sparkfun.com/tutorials/sound-page-guide#hacking-your-kit . I was able to get those .wav files working from the tutorial. It looks like he reduced the file size to mono and 22050 Hz for the project rate in Audacity. Testing this on a customer's .wav files exported as a "signed 16-bit PCM", I was able to get a clearer sound. Try modifying the .wav files with that configuration. The issue is that the rate is reduced and the audio track has been converted from stereo to mono. I'm not exactly sure why 32000 Hz and 44100 Hz rates with stereo and .wav files as signed 16-bit PCM do not work. Maybe the VS1053B cannot handle the quality of the wav files and the datasheet is wrong?

  • Member #596676 / about 10 years ago / 1

    Right now I am testing the Lilypad mp3 with headphones, but I wanted to change the volume of the L channel independently than that of the R channel (for starters)… Trying simple panning in here…

    Thought it would be enough by placing different numbers within the code, say: include <SPI.h> // To talk to the SD card and MP3 chip include <SdFat.h> // SD card file system include <SFEMP3Shield.h> // MP3 decoder chip include <Wire.h> // to talk to the Amplifier chip include <SFE_TPA2016D2.h>

    (…)

    MP3player.setVolume(5,30);

    For some reason volume is kept the same in both headphones, as if one number will override the other? Why is this?

    Should I use separated speakers (LEFT SPEAKER/RIGHT SPEAKER) directly from their terminals in this Lilypad board? Or is it that I am just not seeing something really obvious within the code?

    Thanks!


If you've found an issue with this tutorial content, please send us your feedback!