1

I am getting this error from the Visual Studio compiler (I use the Visual Studio add-in Visual Micro for Arduino).

ModelRailroadCrossingSignalController.ino:In function 'void loop() ModelRailroadCrossingSignalController.ino:210:15: error: too few arguments to function 'Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer, const char*) :onSignalSound() ModelRailroadCrossingSignalController.ino:note declared here :Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) { Error compiling project sources

Here is the function and loop (all the defines and instances left out for brevity, they aren't the issue

void loop() {
// put your main code here, to run repeatedly

signalEntrySensor = checkEntrySensor();
if (signalEntrySensor == true) {
    if (crossingSignalInOperation == false)
    {
        Adafruit_VS1053_FilePlayer mp = onSignalSound(musicPlayer,"Trainxng.mp3");  //all other functions are called in the sound routine?
        if (debugMode)
        {
            Serial.println("Sound byte called");
        }
        while (mp.playingMusic) {
            // file is now playing in the 'background' so now's a good time
            // to do something else 
            offRoadPower();
            lowerSignalArms();
            onSignalSound();
            startSignalFlashers();
            crossingSignalInOperation = true;
        }                   
    }
}

Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) {
// Play the train crossing sound file
if (debugMode)
{
    Serial.println(F("Playing track - "));
    Serial.print(fileName);
}
//all sound files are on the micro sd card on the music player shield
if (!mp.startPlayingFile(fileName)) {
    Serial.println(F("Could not open file "));
    Serial.print(fileName);
    while (1);
}
return mp;  }

I'm a C# guy, not ever using C++ until now, but this code should certainly work, not sure why the function is not compiling.

0

The clue is in the error...

too few arguments to function 'Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer, const char*)

You have defined the function as this:

Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) {

And yet you then try and call it like this:

onSignalSound();

Spot the mismatch?

I suspect you don't want to be calling that function there since it seems to be in a bit where the sound has already been started.

  • not sure how i missed that, I had it commented out earlier – dinotom Apr 12 '16 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.