IR Receiver

I've been trying to set up an IR Receiver for part of my college project, and have received countless migraines trying to get it to work properly.

I've scoured google for answers to this problem, which has involved me rolling the IDE back to version 1.0.5, and every other version since then (currently using 1.6.4), downloading several tutorials and pre-written sketches, and downloading "fixed" libraries.
None of the offered solutions have worked, and all of the sketches and libraries I've tested have flagged the same errors. (The infamous "TKD2 not defined" error)

I've attempted to define the value of TKD2 as an int with an open value, and with a value of '11' to correspond with the sketches I've been using, but this has brought up "multiple definition" errors on the "results" and the "RECV_PIN" variables.

See below, the code I have been using:

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

After defining TKD2 to 11, I receive these error messages:

Arduino: 1.6.4 (Windows 7), Board: "Arduino Uno"

Robot IR Remote\IRremoteTools.cpp.o:(.bss.irrecv+0x0): multiple definition of `irrecv'
IRrecvDemo.cpp.o:(.bss.irrecv+0x0): first defined here
Robot IR Remote\IRremoteTools.cpp.o: In function `beginIRremote()':
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src/IRremoteTools.cpp:14: multiple definition of `results'
IRrecvDemo.cpp.o:C:\Program Files (x86)\Arduino/IRrecvDemo.ino:24: first defined here
Robot IR Remote\IRremoteTools.cpp.o: In function `beginIRremote()':
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src/IRremoteTools.cpp:14: multiple definition of `RECV_PIN'
IRrecvDemo.cpp.o:C:\Program Files (x86)\Arduino/IRrecvDemo.ino:24: first defined here
collect2.exe: error: ld returned 1 exit status
Error compiling.

I've double-checked all the associated library files for multiple definitions, but as far as I can see, there are none.

Any help on this subject would be greatly appreciated!

The IRrecvDemo example from the IRremote library compiles fine for me under 1.6.4 on a Mac. The library is installed in /Users/john/Documents/Arduino/libraries/IRremote and the IDE uses that instead of /Applications/Arduino 1.6.4.app/Contents/Java/libraries/RobotIRremote. Where is your copy of the IRremote library installed?

They really should have re-named all the files from IRremote to RobotIRremote to avoid this conflict.

Build options changed, rebuilding all
Multiple libraries were found for "IRremote.h"
 Used: /Users/john/Documents/Arduino/libraries/IRremote
 Not used: /Applications/Arduino 1.6.4.app/Contents/Java/libraries/RobotIRremote

Sketch uses 8,936 bytes (3%) of program storage space. Maximum is 253,952 bytes.
Global variables use 405 bytes (4%) of dynamic memory, leaving 7,787 bytes for local variables. Maximum is 8,192 bytes.

Found the IRremote library again, removed the RobotIRremote library and that appears to have fixed everything. Thanks John!

Just wanted to say I was having the same problem as solarregis and removing the RobotIRremote folder from my library fixed the error I was getting. (running version 1.7.8 on Mac OS)

Thanks Shannon

This is mentioned in the 'IRremote' library documentation. I saw it, removed "RobotIRremote" before installing "IRremote", so never had a problem.

The moral of the story:-
Reading the documentation carefully when installing new libraries can avoid many issues of this type.