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!