0
votes
#include "IRremote.h"

int receiver = 11;

IRrecv irReceiver(receiver);
decode_results results;

void setup() {
  // put your setup code here, to run once:
pinMode(buttonPinA, INPUT_PULLUP);
pinMode(buttonPinB, INPUT_PULLUP);
pinMode(buttonPinC, INPUT_PULLUP);
pinMode(buttonPinD, INPUT_PULLUP);
irReceiver.enableIRIn();
}

The error message is:

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':

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

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

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

collect2.exe: error: ld returned 1 exit status

exit status 1 Error compiling for board Arduino/Genuino Mega or Mega 2560.

I have recently discovered that "tone" and "IRremote" commands use timer2 from here. I am unaware of what timer2 really is and how to change it.

1
Do you have any definitions in your IRremote.h header file?Paul
You should explain for problem more deeply than sharing code and error messagePararera
I'll bet you could remove at least 90% of that code and still get the problem. Don't ask people to wade through all that irrelevant stuff; condense it as much as you can.Pete Becker

1 Answers

0
votes

This error is a link-time issue. Two pieces of library code have both declared something with the same name (in this case it's a timer).

So the compilation was all OK, and now the linker is taking the compiled output and is wrapping it into an executable. Every time you see an error message like error: ld returned ..., know it's a link problem, and not a syntax issue. Anything ld is the linker ("ld" is the name of the linker program).

As described here:

https://forum.arduino.cc/index.php?topic=120955.msg2613823#msg2613823

Edit the header file IRRemote.h and change which timer interrupt the library uses:

Change the selection:

#define IR_USE_TIMER1   // tx = pin 9
// #define IR_USE_TIMER2     // tx = pin 3

e.g.:

// #define IR_USE_TIMER1   // tx = pin 9
#define IR_USE_TIMER2     // tx = pin 3