0

The error shown is

C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp/core.a(Tone.cpp.o): In function `__vector_7':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of `__vector_7'
C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp\IRremote\IRremote.cpp.o:C:\Users\Siddharth Yadav\Documents\Arduino\libraries\IRremote/IRremote.cpp:361: first defined here
collect2.exe: error: ld returned 1 exit status

Error snapshot

Why is this happening?

The code is:

#include <IRremote.h>
const int echo = 7;// connected to ultrasonic sensor's echo
const int trig = 8;// connected to ultrasonic sensor's trig
const int Right1 = 10;
const int Right2 = 11;
const int Left1 = 12;
const int Left2 = 9;// change this to any other pin; except pin 13
const int buzzer = 5;
const int rightIR = 3;// change here
const int leftIR = 2;// change here
int RECV_PIN = 4;
const int forward = 51;
const int backward = 36;
const int left = 19;
const int right = 0;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
 pinMode(buzzer, OUTPUT);
 pinMode(echo, INPUT_PULLUP);
 pinMode(rightIR, INPUT_PULLUP);
 pinMode(leftIR, INPUT_PULLUP);
 pinMode(trig, OUTPUT);
 pinMode(Right1, OUTPUT);
 pinMode(Right2, OUTPUT);
 pinMode(Left1, OUTPUT);
 pinMode(Left2, OUTPUT);
 sing(1);
 Serial.begin(9600);
 irrecv.enableIRIn(); // Start the receiver
}
void loop() {
 digitalWrite(13, HIGH);
 if (calcDistance() > 30 && !isRight() && !isLeft())
 {
 if (irrecv.decode(&results))
 {
 Serial.println(results.value, HEX);
 irrecv.resume(); // Receive the next value
 delay(50);
 }
 else {
 moveForward();
 }
 }
 else
 {
 delay(10);
 int dist = calcDistance();
 if (dist < 30 && isLeft() && isRight())
 {
 Serial.println("Moving backward");
 tone(buzzer, 4699, 10);
 moveBackward();
 delay(1000);
 }
 else if (isLeft())
 {
 turnRight();
 digitalWrite(13, LOW);
 tone(buzzer, 104, 10);
 Serial.println("Turning Right");
 }
 else if (isRight())
 {
 turnLeft();
 digitalWrite(13, LOW);
 delay(300);
 tone(buzzer, 880, 10);
 Serial.println("Turning LEft");
 }
 else if (dist < 30)
 {
 turnRight();
 digitalWrite(13, LOW);
 tone(buzzer, 104 , 10);
 Serial.println("Turning Right");
 }
 }
 delay(20);
}
asked Apr 22, 2015 at 11:41
2
  • Can you get a more readable shot of the messages? Or cut-and-paste them? This image is pretty difficult to read. Commented Apr 22, 2015 at 12:07
  • C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp/core.a(Tone.cpp.o): In function __vector_7': C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of __vector_7' C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp\IRremote\IRremote.cpp.o:C:\Users\Siddharth Yadav\Documents\Arduino\libraries\IRremote/IRremote.cpp:361: first defined here collect2.exe: error: ld returned 1 exit status Commented Apr 22, 2015 at 12:18

2 Answers 2

1

As the error message says you have multiple definitions of __vector_7 which is defined in: IRemote.cpp:361 and Tone.cpp:536

Tone.cpp is arduino standart lib. If IRemote is a lib of yours then you should edit the cpp file and change the symbol to sth else.

answered Apr 22, 2015 at 12:14
1

The IRemote.cpp and Tone.cpp would be using the same interrupt vector. I believe it's ISR(TIMER5_COMPA_vect) {

  • You could. I don't think it's the best solution, but go to Tone.cpp and comment the ISR(TIMER5_COMPA_vect) { like /*ISR(TIMER5_COMPA_vect)*/void XunusedX(void) {. And be sure to never use any function from ...

  • You could also try to find a way on how not to invoke Tone.h with core.a. include <Tone.h> could be replaced with //include <Tone.h>

  • You could use another timer in IRRemote.h

answered Apr 22, 2015 at 13:43
1
  • This answer is better than mine :) Commented Apr 18, 2016 at 15:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.