[Solved] IRremote and tone conflict

hey so i’m doing a project at the moment and I’m trying to use the IRremote function but its giving me this error

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

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

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

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Nano.

I’m using a nano
and i have my buzzer connect to pin 5 as to below
already did the fix of doing this

// 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


but its still giving me the same error
is there anything else im missing?

file code
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

IRsend irsend;
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 3; // the number of the LED pin
const int buzzer = 5; // pin for the buzzer
int buttonState = 0; // variable for reading the pushbutton status

void setup()
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(buzzer, OUTPUT);

int blah = 0;

void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
irsend.sendNEC(0x80C, 32);
Serial.print("on ");

else {
// turn LED off:
digitalWrite(ledPin, LOW);

Serial.println(“Switch is not pressed”);

testing.ino (969 Bytes)

There is a conflict because both libraries uses the same timer. You can change the timer used in the library source(.cpp and .h files) or use the Newtone library that uses a different timer.

To switch timer for IRremote library, just edit the file IRremoteInt.h in Documents/Arduino/Libraries/IRremote

search for line:
#define IR_USE_TIMER2

comment this line and uncomment the line for another time.

(watch the model in the commented line before the timer like "// Arduino Mega")

:smiley: thank you the NewTone library works like a charm


Tim Eckel has another solution also: