Home Forums Sparkfun MP3 Shield Library Support Forum compile error: SetVolume

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #2610


    First,  I’m a Arduino(and programming) newbie just trying to learn this stuff.  I’ve done several projects in the Arduino book. I apologize it this is a cross post (or trite), but I’ve been searching around and just can’t seem to figure out the clues to make this work for my project.

    I’m using the UNO R3,  mp3 player along with a pir motion sensor for this project.

    I modeled my project after this cemetery howler project:  http://www.youtube.com/watch?v=PKG3XRzcdRg

    My pir sensor works, my mp3 player works when using test sketches.

    (I believe) I have all the correct libraries in my sketch.   I’ve done my research on libraries and installing them etc… I have the latest ones installed.


    Anyways, I don’t know what the heck is wrong, but here’s my error:

    sketch_may05a.ino: In function ‘void setup()’:

    sketch_may05a:43: error: ‘class SFEMP3Shield’ has no member named ‘SetVolume’


    Any ideas would be very helpful.  Thanks!

    Here’s my code:

    // libraries

    #include <SPI.h>

    #include <SdFat.h>

    #include <SdFatUtil.h>

    #include <SFEMP3Shield.h>

    SFEMP3Shield MP3player;

    // constant variables

    int pirPin = 5;                                  // PIR sensor input pin

    int calibrationTime = 10;

    unsigned long playTime = 15000;      // how long a file will play in milliseconds (15000=15 seconds)

    unsigned long pauseTime = 10000;     // how long the pause will be after the sound ends (10000=10 seconds)

    int readingInterval = 20;            // how often to read the sensor


    // changing variables

    int rantrack = 0;                               // track number for randomizing

    unsigned long currentMillis = 0;     // time variable to track running time: current time

    unsigned long startingMillis = 0;    // time variable to track running time: starting time

    byte result;                         // variable for mp3 player shield, can be used to debug

    // setup

    void setup() {

    pinMode(pirPin, INPUT);

    digitalWrite(pirPin, LOW);


    //give the sensor some time to calibrate

    for(int i = 0; i < calibrationTime; i++){





    pinMode(pirPin, INPUT);                        // make PIR sensor an input

    digitalWrite(pirPin, LOW);                    // activate internal pull-up resistor

    result = MP3player.begin();                      // start mp3 player shield

    MP3player.SetVolume(10,10);                 //this is highlighted during error,   set volume of the mp3 player ( 0 = loudest )


    // loop

    void loop(){

    if (digitalRead(pirPin)== HIGH) {                // if movement sensed

    randomSeed(millis());                        // set a more random seed for the random function

    rantrack = random(5);                       // find random number

    result = MP3player.playTrack(rantrack);      // play track

    playtime();                                  // call function for play time

    MP3player.stopTrack();                        // stop track

    delay(pauseTime);                            // wait…


    delay(readingInterval);                          // wait with reading


    // function to determine playtime

    void playtime() {

    startingMillis = millis();                                 // set both time counter

    currentMillis = millis();

    while ( currentMillis – startingMillis < playTime ) {      // while track plays, runs until playTime is reached

    currentMillis = millis();                               // set to actual time

    delay(40);                                              // debounce




    Thanks again,



    I have posted GISTHUB with corrected code that compiles at https://gist.github.com/mpflaga/5522030#file-froggy14_mp3_pir-ino

    You were basically correct. The pasting of code into wordpress’s web page altered several characters, creating some additional errors.

    I believe there were some invisible(or altered) characters in the setVolume line that was making the call not match the signature of the available member functions, resulting in your error.

    I simply deleted the whole line and re-typed it. Where a cut and paste carried the problem.

    Additionally you needed to instance the “SdFat sd;” object.


    Hi Michael,

    Sweet, it’s finally compiling!

    Now, I’m having an issue with not hearing anything. However,  I mistakenly purchased a different pir sensor (not the the parralax) which is used in the project I’m referencing.  I’m hoping my issue is on the hardware end at this point.

    I’ll let you know how it goes.

    Thanks a ton for your help,  I really appreciate it!



    Great. I recommend you add debug prints so that you know what the code is seeing as input and attempting to do.
    Have fun.


    Hi Michael Flaga,

    I’m trying to use your code but for some reason an mp3 file won’t play. Have you made any updates to the one provided on github? Thank you!


    https://github.com/mpflaga/Sparkfun-MP3-Player-Shield-Arduino-Library is the most recent. It is the beta version.

    Please review the documentation’s Trouble shooting section


    I got the same error and tried the corrected code, I still get an error. Perhaps Michael could give me an advice on how to resolve it. I’m using a Geeetech VS1053 MP3 shield which might account for the error.

    My error message:

    Documents\Arduino\libraries\SFEMP3Shield\SFEMP3Shield.cpp:2107: error: ‘MP3_DREQINT’ was not declared in this scope



    I have a GeeeTech. It has been a while and recall it work straight up, as it is identical pin out as a SparkFun MP3 Shield.

    I would suspect that your problem is occurring from some setting between your selected board and the define of MP3_DREQINT that is located in http://mpflaga.github.io/Sparkfun-MP3-Player-Shield-Arduino-Library/_s_f_e_m_p3_shield_config_8h_source.html

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.