Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Music Maker MP3 Shield not working properly
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Music Maker MP3 Shield not working properly

by adafruit_support_mike on Sun May 24, 2015 10:18 pm

Only one file can play at a time.

adafruit_support_mike
 
Posts: 61221
Joined: Thu Feb 11, 2010 2:51 pm

Re: Music Maker MP3 Shield not working properly

by HansvB on Mon May 25, 2015 5:02 pm

Thanks for helping me out

HansvB
 
Posts: 8
Joined: Fri May 08, 2015 7:31 pm

Re: Music Maker MP3 Shield not working properly

by owly on Thu Dec 15, 2016 3:07 am

I'm trying to make the shield audio player work but it keeps saying it can't find it.
From a few other posts it seems the most likely reason it wouldn't work is poor soldering.
Here's a picture of my board: https://goo.gl/photos/SJUiRSjKP6Ymop81A
Did I miss something obvious?

owly
 
Posts: 1
Joined: Thu Dec 15, 2016 3:03 am

Re: Music Maker MP3 Shield not working properly

by adafruit_support_mike on Fri Dec 16, 2016 2:35 am

Yeah, several of the solder joints in that photo need work.

Take a look at our Guide to Excellent Soldering and retouch the joints. Giving each one a dab of flux before heating it will make life easier.

https://learn.adafruit.com/adafruit-gui ... -soldering

adafruit_support_mike
 
Posts: 61221
Joined: Thu Feb 11, 2010 2:51 pm

Re: Music Maker MP3 Shield not working properly

by ribes on Sat Feb 25, 2017 3:57 pm

Hello - I am having a problem where the shield will only play 8 or 9 songs and then it says it cannot open file. It is set to loop and so it keeps trying with the same 'cannot open file'. I tried it with two different shields, two sd cards, two Uno, so it must be in the code. Here is the code (thank you for this forum!):

Code: Select all | TOGGLE FULL SIZE
// include SPI, MP3, Servo and SD libraries
#include <SPI.h>             // We will use the hardware SPI pins: CLK (13), MISO (12), MOSI (11)
#include "Adafruit_VS1053.h"
#include <SD.h>
int track1, track2, track3, track4, track5;
const int pingPin = 8;
const int echoPin = 9;
unsigned int duration, inches;
const char* zone1[][15] = {"track001.mp3", "track002.mp3", "track003.mp3", "track004.mp3", "track005.mp3", "track006.mp3", "track007.mp3", "track008.mp3", "track009.mp3", "track010.mp3", "track011.mp3", "track012.mp3", "track013.mp3", "track014.mp3", "track015.mp3", "track016.mp3", "track017.mp3", "track018.mp3", "track019.mp3", "track020.mp3"};
String thetrack;



// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS      7      // VS1053 chip select pin (output)
#define SHIELD_DCS     6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer =

Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

void setup() {


  track1 = 0;
  track2 = 0;
  track3 = 0;
  track4 = 0;
  track5 = 0;
  pinMode(8, OUTPUT);
  pinMode(9, INPUT);
  Serial.begin(9600);
  Serial.println("File From Distance Test");

  if (! musicPlayer.begin()) { // initialise the music player
    Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
    while (1);
  }
  Serial.println(F("VS1053 found"));

  SD.begin(CARDCS);    // initialise the SD card
  printDirectory(SD.open("/"), 0);
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(2 , 2);
}

void ping()  {
  digitalWrite(pingPin, LOW);        // Ensure pin is low
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);       // Start ranging
  delayMicroseconds(5);              //   with 5 microsecond burst
  digitalWrite(pingPin, LOW);        // End ranging

  duration = pulseIn(echoPin, HIGH); // Read echo pulse
  inches = duration / 74 / 2;        // Convert to inches
  //Serial.println(inches);            // Display result
  if ((inches > 61) && (inches < 96)) {
    Serial.println("t1");
    delay(1000);
  }
  if ((inches > 45) && (inches < 60))  {
    Serial.println("t2");
    delay(1000);
  }
  if ((inches > 29) && (inches < 44))  {
    Serial.println("t3");
    delay(1000);
  }
    if ((inches > 19) && (inches < 28))  {
    Serial.println("t4");
    delay(1000);
  }
    if ((inches > 3) && (inches < 18))  {
    Serial.println("t5");
    delay(1000);
  }

}

void loop() {
  delay(50);
  ping();
 
  if ((inches > 61) && (inches < 96)) {
    if (track1 == 0) {
      File path = SD.open("/FIRST_~1");
      File results;
      char* MP3 = selectRandomFileFrom( path, results );
      Serial.println(MP3);
      if (! musicPlayer.playFullFile(MP3)) {
        Serial.println("Could not open file: ");
        Serial.println(MP3);
      }

      Serial.print(F("Now playing "));
      Serial.println(MP3);
      while (musicPlayer.playingMusic) {

        //////////////////////////////////////////////////////////////////////////////////////////////////////////
      }
        Serial.print("Done playing: ");
        Serial.println(MP3);
        Serial.println();
      }}

      if ((inches > 45) && (inches < 60)) {
        if (track2 == 0) {
          File path = SD.open("/SECOND~1");
          File results;
          char* MP3 = selectRandomFileFrom( path, results );
          Serial.println(MP3);
          if (! musicPlayer.playFullFile(MP3)) {
            Serial.println("Could not open file: ");
            Serial.println(MP3);
          }

          Serial.print(F("Now playing "));
          Serial.println(MP3);
          while (musicPlayer.playingMusic) {

            //////////////////////////////////////////////////////////////////////////////////////////////////////////
          }
            Serial.print("Done playing: ");
            Serial.println(MP3);
            Serial.println();

           //track2=0
        } //inches
      }
        if ((inches > 29) && (inches < 44)) {
          if (track3 == 0) {

            File path = SD.open("/THIRD_~1");
            File results;
            char* MP3 = selectRandomFileFrom( path, results );
            Serial.println(MP3);
            if (! musicPlayer.playFullFile(MP3)) {
              Serial.println("Could not open file: ");
              Serial.println(MP3);
            }

            Serial.print(F("Now playing "));
            Serial.println(MP3);
            while (musicPlayer.playingMusic) {

              //////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
              Serial.print("Done playing: ");
              Serial.println(MP3);
              Serial.println();

           
          }
        }

        if ((inches > 19) && (inches < 28)) {
          if (track4 == 0) {

            File path = SD.open("/FOURTH~1");
            File results;
            char* MP3 = selectRandomFileFrom( path, results );
            Serial.println(MP3);
            if (! musicPlayer.playFullFile(MP3)) {
              Serial.println("Could not open file: ");
              Serial.println(MP3);
            }

            Serial.print(F("Now playing "));
            Serial.println(MP3);
            while (musicPlayer.playingMusic) {

              //////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
              Serial.print("Done playing: ");
              Serial.println(MP3);
              Serial.println();

           
          }
        }


               if ((inches > 3) && (inches < 18)) {
          if (track5 == 0) {

            File path = SD.open("/FIFTH_~1");
            File results;
            char* MP3 = selectRandomFileFrom( path, results );
            Serial.println(MP3);
            if (! musicPlayer.playFullFile(MP3)) {
              Serial.println("Could not open file: ");
              Serial.println(MP3);
            }

            Serial.print(F("Now playing "));
            Serial.println(MP3);
            while (musicPlayer.playingMusic) {

              //////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
              Serial.print("Done playing: ");
              Serial.println(MP3);
              Serial.println();

           
          }
        }



       
}
        char* selectRandomFileFrom( File dir, File result ) {
          File entry;
          int count = 1;

          dir.rewindDirectory();

          while ( entry = dir.openNextFile() ) {
            if ( random( count ) == 0 ) {
              result = entry;
            }
            entry.close();
            count++;
          }
          Serial.println(count);
          return result.name();   // returns the randomly selected file name
        }

        void printDirectory(File dir, int numTabs) {
          while (true) {

            File entry =  dir.openNextFile();
            if (! entry) {
              // no more files
              //Serial.println("**nomorefiles**");
              break;
            }
            for (uint8_t i = 0; i < numTabs; i++) {
              Serial.print('\t');
            }
            Serial.print(entry.name());
            if (entry.isDirectory()) {
              Serial.println("/");
              printDirectory(entry, numTabs + 1);
            } else {
              // files have sizes, directories do not
              Serial.print("\t\t");
              Serial.println(entry.size(), DEC);
            }
            entry.close();
          }
        }


ribes
 
Posts: 2
Joined: Sat Feb 25, 2017 3:53 pm

Re: Music Maker MP3 Shield not working properly

by jim_lee on Sat Feb 25, 2017 5:28 pm

Looks like you keep opening new

File path = SD.open("/FOURTH~1");
File results;

You never close() them. Although they go out of scope, they like to be closed() first.

-jim lee

jim_lee
 
Posts: 636
Joined: Thu May 24, 2012 8:24 pm

Re: Music Maker MP3 Shield not working properly

by ribes on Sat Feb 25, 2017 6:23 pm

@jim_lee - Jim thank you for your response!
I am new here and don't know much about coding.
Where in the code would I close() if you don't mind my asking?
Thank you!
Riah

ribes
 
Posts: 2
Joined: Sat Feb 25, 2017 3:53 pm

Re: Music Maker MP3 Shield not working properly

by jim_lee on Sat Feb 25, 2017 10:43 pm

Call these as soon as your done with them.

path.close();
results.close();

Don't feel alone. A vast percentage of the people through these Arduino forums are on their first few lines of code.

-jim lee

jim_lee
 
Posts: 636
Joined: Thu May 24, 2012 8:24 pm

Re: Music Maker MP3 Shield not working properly

by hulig on Sun Mar 04, 2018 6:52 pm

I am running in to an issue. I uploaded the player_simple and when I run it I get:

Adafruit VS1053 Simple Test
VS1053 found
SYSTEM~1/
WPSETT~1.DAT 12
INDEXE~1 76
TRACK001.MP3 198529
TRACK002.MP3 170317
Playing track 001
Playing track 002
Done playing music

But nothing plays over my headphones when connected to the audio jack. I can play the tracks from my SD when it's plugged in to my computer so at this point I'm lost.
This is my first build and any help would be greatly appreciated!

hulig
 
Posts: 1
Joined: Sun Mar 04, 2018 6:43 pm

Please be positive and constructive with your questions and comments.