I get the following error when compiling the code:
Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Uno"
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
libraries\Arduino-IRremote-master\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/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Please tell me how to rectify this!!
#include <IRremote.h>
#include <AFMotor.h>
AF_DCMotor rightMotor(1); // Right motor connected to port 1
AF_DCMotor leftMotor(2); // Left motor connected to port 2
IRrecv irrecv(A1);// IR receiver connected to pin A1(ANALOG PINS ON MOTOR SHIELD USED AS DIGITAL INS!)
decode_results results;
#define Straight 0xC1CC42BD
#define Right 0xC1CCA25D
#define Left 0xC1CC22DD
#define Back 0xC1CCC23D
void setup(){
Serial.begin(9600); // Establishing Serial Communication
irrecv.enableIRIn(); // Start the receiver
pinMode(A3, OUTPUT); // Set buzzer - pin A3 as an output
for(int i=0; i<200 ; i+=50){
tone(A3, i);
delay(1000);
}
}
void loop() {
if (irrecv.decode(&results)){ //Have we received an IR signal??
translateIR();
irrecv.resume(); // Receive the next value
}
}
void translateIR(){
switch(results.value){
case Straight:
moveForward();
break;
case Right:
turnRight();
break;
case Left:
turnLeft();
break;
case Back:
moveBackward();
break;
default:
Stop();
break;
}
}
void moveForward() {
buzz();
leftMotor.setSpeed(255);
rightMotor.setSpeed(255);
leftMotor.run(FORWARD);
rightMotor.run(FORWARD);
}
void turnRight(){
buzz();
leftMotor.setSpeed(200);
rightMotor.setSpeed(200);
leftMotor.run(FORWARD);
rightMotor.run(BACKWARD);
delay(400);
leftMotor.run(FORWARD);
rightMotor.run(FORWARD);
}
void turnLeft() {
buzz();
leftMotor.setSpeed(200);
rightMotor.setSpeed(200);
leftMotor.run(BACKWARD);
rightMotor.run(FORWARD);
delay(400);
leftMotor.run(FORWARD);
rightMotor.run(FORWARD);
}
void moveBackward() {
buzz();
leftMotor.setSpeed(200);
rightMotor.setSpeed(200);
leftMotor.run(BACKWARD);
rightMotor.run(BACKWARD);
}
void Stop(){
leftMotor.setSpeed(0);
rightMotor.setSpeed(0);
}
void buzz(){
tone(A3,100);
delay(500);
}