tone() function and IRRemote master library.

Hi,

I got this error

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

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

C:\Users\ERMANU~1\AppData\Local\Temp\arduino_build_6473\libraries\Arduino-IRremote-master\IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

Using library Arduino-IRremote-master at version 2.2.3 in folder: C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master
exit status 1
Error compiling for board Arduino/Genuino Uno."

when i try to use tone function with IRRemote master library.

Anybody have any idea about this ?

Thank you.

They both use Timer2.

I've posted the solution a couple of times :wink: Do a search for my username in combination with irremote to find out the approach.

The below applies to the IRremote library that has a boarddefs.h. Find the boarddefs.h file; it should be in C:\Users\YourUserName\Documents\Arduino\libraries\IRremote

Edit the boarddefs.h file using a normal editor (I use notepad++).

Find this section (around line 191)

#else
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
// ATmega48, ATmega88, ATmega168, ATmega328
	//#define IR_USE_TIMER1   // tx = pin 9
	#define IR_USE_TIMER2     // tx = pin 3

And change it to

#else
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
// ATmega48, ATmega88, ATmega168, ATmega328
	#define IR_USE_TIMER1   // tx = pin 9
	//#define IR_USE_TIMER2     // tx = pin 3

This will tell the compiler to use Timer1 instead of Timer2.

If your library does not have a boarddefs.h, the file to modify is IRremoteInt.h (if I recall correctly); what your looking for is on other lines though.

Note:
This change will affect any previous projects as well as future projects that make use of Timer1 !! If you want to prevent this, you will have to make a copy of the IRremote library to the sketch folder; that however is another chapter.

PS
You can probably also modify the tone library; I have never looked into that.