Conflicting Servo and AltSoftSerial Libraries?

Hi all,

I'd love some advice on what I could do here. I'm trying to make a barking, jaw moving, LED-eyed dog. I'm using servo and altsoftserial library with an arduino uno but it refuses to compile for Uno. I believe this is, due to the error messages, to do with the same thing being defined in both libraries, though it would be great if someone could confirm this and advise on what the best thing to do is.

I'm not sure if it would mean diving into the library and deleting one of them but I'm sure that would get messy, I can think of other workarounds but just requiring more components and faff.

I've bolded in the error messages where I think the error is, but obviously could be completely wrong.

Code for the project:

#include <AltSoftSerial.h>
#include <Servo.h>
#include <MD_YX5300.h>
AltSoftSerial altSerial;
MD_YX5300 mp3(altSerial);
#define LEDleft 10
#define LEDright 11
#define PIR 13
Servo servo;

void setup() {

  pinMode(LEDleft, OUTPUT);
  pinMode(LEDright, OUTPUT);
  pinMode(PIR, INPUT);
  altSerial.begin(9600);
  mp3.begin();
  mp3.setSynchronous(true);
  mp3.volume(30);
  mp3.playTrack(1);

  //servo.attach(6);
}

void loop() {

if (digitalRead(PIR) == HIGH) {
    digitalWrite(LEDleft, HIGH);
    delay(500); 
} else {
  digitalWrite(LEDleft, LOW);
}
}

And Error messages are as follows:

Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"

In file included from C:\Users\BenCl\Google Drive\Game Materials, Soundtracks etc\Zombie\Arduino Final Codes\Dog\Dog\Dog.ino:1:0:

C:\Users\BenCl\Documents\Arduino\libraries\AltSoftSerial/AltSoftSerial.h: In constructor 'AltSoftSerial::AltSoftSerial(uint8_t, uint8_t, bool)':

C:\Users\BenCl\Documents\Arduino\libraries\AltSoftSerial/AltSoftSerial.h:63:24: warning: unused parameter 'rxPin' [-Wunused-parameter]

AltSoftSerial(uint8_t rxPin, uint8_t txPin, bool inverse = false) { }

                    ^~~~~

C:\Users\BenCl\Documents\Arduino\libraries\AltSoftSerial/AltSoftSerial.h:63:39: warning: unused parameter 'txPin' [-Wunused-parameter]

AltSoftSerial(uint8_t rxPin, uint8_t txPin, bool inverse = false) { }

                                   ^~~~~

C:\Users\BenCl\Documents\Arduino\libraries\AltSoftSerial/AltSoftSerial.h:63:61: warning: unused parameter 'inverse' [-Wunused-parameter]

AltSoftSerial(uint8_t rxPin, uint8_t txPin, bool inverse = false) { }

                                                         ^~~~~

C:\Users\BenCl\Documents\Arduino\libraries\AltSoftSerial/AltSoftSerial.h: In static member function 'static void AltSoftSerial::enable_timer0(bool)':

C:\Users\BenCl\Documents\Arduino\libraries\AltSoftSerial/AltSoftSerial.h:68:33: warning: unused parameter 'enable' [-Wunused-parameter]

static void enable_timer0(bool enable) { }

                             ^~~~~~

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `__vector_11'

libraries\AltSoftSerial\AltSoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "Servo.h"

Used: C:\Users\BenCl\Documents\Arduino\libraries\Servo

Not used: C:\Program Files (x86)\Arduino\libraries\Servo

exit status 1

Error compiling for board Arduino Uno.

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

Many thanks
Ben

Hi Ben. You may be right. I remember that the AltSoftSerial library has some advantages over the standard SoftwareSerial library, but may use some resource of the AVR chip that the Servo library also needs. In your project, I suspect the advantages of AltSoftSerial are of no benefit at all.

So maybe try the standard SoftwareSerial library instead.

PS. Please always post compiler error messages inside code tags.

Or if you really do need AltSoftSerial for some reason then try ServoTimer2.h instead of the standard Servo.h (but note that it uses microseconds not angles in the write() command).

Steve

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.