Multiple libaries were found for "SoftwareSerial.h"

Hi everyone,

I want to code a programm that plays sounds with DFPlayer and a small speaker.

First I found one sample code from the internet that I want to change. It works in the tutorial, but when I'm trying to upload it on my Arduino I get some errors:

Arduino: 1.8.10 (Windows 8.1), Board: "Arduino Uno"

C:\Users\User\Desktop\Joystick\DFPlayer-test\DFPlayer-test.ino: In function 'void setup()':

DFPlayer-test:28:1: error: 'playFirst' was not declared in this scope

playFirst();

^~~~~~~~~

C:\Users\User\Desktop\Joystick\DFPlayer-test\DFPlayer-test.ino: In function 'void loop()':

DFPlayer-test:40:7: error: 'pause' was not declared in this scope

   pause();

   ^~~~~

DFPlayer-test:45:7: error: 'play' was not declared in this scope

   play();

   ^~~~

C:\Users\User\Desktop\Joystick\DFPlayer-test\DFPlayer-test.ino:45:7: note: suggested alternative: 'delay'

   play();

   ^~~~

   delay

DFPlayer-test:54:7: error: 'playNext' was not declared in this scope

   playNext();

   ^~~~~~~~

DFPlayer-test:62:7: error: 'playPrevious' was not declared in this scope

   playPrevious();

   ^~~~~~~~~~~~

C:\Users\User\Desktop\Joystick\DFPlayer-test\DFPlayer-test.ino:62:7: note: suggested alternative: 'buttonPrevious'

   playPrevious();

   ^~~~~~~~~~~~

   buttonPrevious

Multiple libraries were found for "SoftwareSerial.h"
Used: C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\SoftwareSerial
exit status 1
'playFirst' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The code is:

#include "SoftwareSerial.h"

SoftwareSerial mySerial(10, 11);
#define Start_Byte 0x7E
#define Version_Byte 0xFF
#define Command_Length 0x06
#define End_Byte 0xEF
#define Acknowledge 0x00

#define ACTIVATED LOW

int buttonNext = 2;
int buttonPause = 3;
int buttonPrevious = 4;
boolean isPlaying = false;

void setup () {

pinMode(buttonPause, INPUT);
digitalWrite(buttonPause,HIGH);
pinMode(buttonNext, INPUT);
digitalWrite(buttonNext,HIGH);
pinMode(buttonPrevious, INPUT);
digitalWrite(buttonPrevious,HIGH);

mySerial.begin (9600);
delay(1000);
playFirst();
isPlaying = true;

}

void loop () {

if (digitalRead(buttonPause) == ACTIVATED)
{
if(isPlaying)
{
pause();
isPlaying = false;
}else
{
isPlaying = true;
play();
}
}

if (digitalRead(buttonNext) == ACTIVATED)
{
if(isPlaying)
{
playNext();
}
}

if (digitalRead(buttonPrevious) == ACTIVATED)
{
if(isPlaying)
{
playPrevious();
}
}
}

If you've got ideas how I can make this code work, I'll be thankful.

Best regards
Kris

You are missing a #include of some DFPlayer library which contains all the functions you are calling in your code.

The multiple libraries for SoftwareSerial.h is not the problem.

1 Like

Read the forum guidelines to see how to post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto Format) to indent the code for readability before posting code.

This specific "Multiple libraries were found for" message was the result of a bug:
https://github.com/arduino/Arduino/issues/9601
It was fixed a couple of years ago, but you're using a super outdated version of the Arduino IDE.

You'll know a legitimate "Multiple libraries were found for" message because it will list the paths of each of the multiple libraries. When you see only a single path, that message results from the bug.

I included "DFRobotDFPlayerMini.h" and defined RX and TX pins and now everything works normally.

Thank you!

Excuse me! I'm new here, I didn't know that.