IRremote library "Error Compilling" Help!

Hello!

I’m working on my DFRobotShop Rover and I’m trying to control my car via Infrared and using IRremote library(https://github.com/shirriff/Arduino-IRremote).

However, After I verify the code it appear the error message:

IRremote\IRremote.cpp.o: In function "MATCH (int , int)’:
/IRremoteInt.h:176:multiple definition of ‘MATCH (int, int)’
sketch_oct21a.cpp.o:C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremoteInt.h:176: first defined here

Below is my code:

////??????????????????????????
#include <IRremote.h>
#include <IRremoteInt.h>


//????????  ?????????????
#define UP    0xC26BF044    //?????UP?
#define DOWN  0xC4FFB646    //?????DOWN?
#define LEFT  0x758C9D82    //?????LEFT?
#define RIGHT 0x53801EE85LL   //?????RIGHT?
#define STOP  0x8AF13528    //?????STOP?

/*To control the rover, Copy and paste the code below into the Arduino software*/
int E1 = 6; //M1 Speed Control
int E2 = 5; //M2 Speed Control
int M1 = 8; //M1 Direction Control
int M2 = 7; //M2 Direction Control



int RECV_PIN = 11;     //????????

IRrecv irrecv(RECV_PIN);//???

decode_results results;//???????


void setup(void)
{
  int i;
  for(i=5;i<=8;i++)
  pinMode(i, OUTPUT);
  Serial.begin(9600);
  
   irrecv.enableIRIn(); // ????
}





void loop(void) 
{
  if (irrecv.decode(&results))
  {
        Serial.println(results.value, HEX);

int leftspeed = 255;
int rightspeed = 255;

        switch(results.value)
        {
              case UP://2???
                forward (leftspeed,rightspeed);
                break;
              case DOWN://4???
                reverse (leftspeed,rightspeed);
                break;
              case LEFT://8???
                left (leftspeed,rightspeed);
                break;
              case RIGHT://6???
                right (leftspeed,rightspeed);
                break;
              case STOP://5???
                stop();
                break;
             default:
                stop();
                delay(100);
        }
        irrecv.resume(); // Receive the next value
  }
      stop();//??????
}





void stop(void) //Stop
{
  digitalWrite(E1,LOW);
  digitalWrite(E2,LOW);
}
void forward(int a,int b)
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);
  analogWrite (E2,b);
  digitalWrite(M2,LOW);
}
void reverse (int a,int b)
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);
  analogWrite (E2,b);
  digitalWrite(M2,HIGH);
}
void left (int a,int b)
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);
  analogWrite (E2,b);
  digitalWrite(M2,LOW);
}
void right (int a,int b)
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);
  analogWrite (E2,b);
  digitalWrite(M2,HIGH);
}

Please help me figure out what’s wrong with my program.

Thank you!
Tony

IRrecvDemo.pde only includes IRremote.h and not IRremoteInt.h. I think you should do the same.

johnwasser: IRrecvDemo.pde only includes IRremote.h and not IRremoteInt.h. I think you should do the same.

Hello! johnwasser,

Thank you for your quick reply. Your suggestion works. However, my Robot Car isn't moving. Can you help me modify my code?

Here is the sample code in Manual on page 23

http://www.robotshop.com/content/PDF/dfrobotshop-rover-user-guide.pdf

Thank you!

Can you help me modify my code?

To do what? You should have written a number of other sketches to verify each piece of hardware. Trying to write one program without testing individual pieces, standalone, is an exercise in frustration.

Did those other sketches work? If not, let us know when you have them all working. Or what they look like and what problems you have with them.

And, "it's not working" should NEVER be your only comment about the code.

Tonyzhang:
Hello!

I’m working on my DFRobotShop Rover and I’m trying to control my car via Infrared and using IRremote library(https://github.com/shirriff/Arduino-IRremote).

However, After I verify the code it appear the error message:

IRremote\IRremote.cpp.o: In function "MATCH (int , int)’:
/IRremoteInt.h:176:multiple definition of ‘MATCH (int, int)’
sketch_oct21a.cpp.o:C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremoteInt.h:176: first defined here

Your not the only one to have this fault. I ran into the same fault today. Generally the answer on forums/instructables has been to change the WProgram.h to Arduino.h in the IRremoteInt.h. This doesn’t work, well it didn’t for me.And why?..

Ken Shirrifs library,https://github.com/shirriff/Arduino-IRremote.git, has been updated so you shouldn’t have to change anything in the library.He has placed a bit of code in there to make it compatable with all versions of Arduino.

That said , when a sketch is compiled, I get the same error as you did. A few examples in the “IR library download” compile ok. If an example has #include <IRremoteInt.h> I get the above fault.
I searched for another version of the library and found one that hadn’t been updated, changed the wprogram.h for arduino .h and all examples now compile without error. I would like to see a fix for the new updated library though, as we all like to run with the newest shiniest code available. But unless Mr. Shirrif reads these post it could be a while.

Thanks to Ken Shirrif for the library.

Stu

ok! Here you go. The following is my code and it work on my rover. Thank you guys.

///??????????????????????????
#include <IRremote.h>


#define E1 6//?????

#define E2 5

#define M1 8//?????

#define M2 7

//????????  ?????????????
#define UP    0xC26BF044    //?????UP?
#define DOWN  0xC4FFB646    //?????DOWN?
#define LEFT  0x758C9D82    //?????LEFT?
#define RIGHT 0x53801EE8   //?????RIGHT?
#define STOP  0x8AF13528    //?????STOP?


int RECV_PIN = 11;     //????????

IRrecv irrecv(RECV_PIN);//???

decode_results results;//???????

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // ????
}

void loop() 
{
  if (irrecv.decode(&results))
  {
        Serial.println(results.value, HEX);

        switch(results.value)
        {
              case UP://2???
              advance(255);
              break;
              case LEFT://4???
              left_handed(255);
              break;
              case DOWN://8???
              retreat(255);
              break;
              case RIGHT://6???
              right_handed(255);
              break;
              case STOP://5???
              stop_m();
              break;
             default:
delay(100);

        }
        irrecv.resume(); // Receive the next value
  }
  



}




void foreward_mechine_a()//?????
{
    analogWrite(E1,255);
    digitalWrite(M1,LOW);

}
void inversion_mechine_a()//?????
{
    analogWrite(E1,255);
    digitalWrite(M1,HIGH);

  
}

void stop_a(void)//?????
{
      digitalWrite(E1,LOW);

}

void stop_b(void)//?????
{
      digitalWrite(E2,LOW);

}

void foreward_mechine_b()//?????
{
    analogWrite(E2,255);
    digitalWrite(M2,LOW);

}
void inversion_mechine_b()//?????
{
    analogWrite(E2,255);
    digitalWrite(M2,HIGH);
 
}
void advance(int time)//????
{
     foreward_mechine_a();
     foreward_mechine_b();
    delay(time);  
}
void retreat(int time)//????
{
      inversion_mechine_a();
      inversion_mechine_b();
      delay(time);  
}

void left_handed(int time)//????
{
    inversion_mechine_a();
    foreward_mechine_b();
    delay(time);
    
}
void right_handed(int time)//????
{
    foreward_mechine_a();
    inversion_mechine_b();
    delay(time);
}
void stop_m(void)//????
{
      stop_a();
      stop_b();
}