Hi. Anyone know why I get a series of errors with this code, to test out an IR Receiver? It's from page 287 of 'Arduino Workshop'.
Errors include : 'IRrecv' does not name a type, 'decode_results' does not name a type.
I imported the IRremote library, but the code still doesn't work.
Don't know a lot of C, so any advice would help. Thanks...
// Listing 15-1
int receiverpin = 11; // pin 1 of IR receiver to digital pin 11 #include <IRremote.h> // use the library
IRrecv irrecv(receiverpin); // create instance of irrecv
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // start the IR receiver
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.print(results.value, HEX); // display IR code on Serial Monitor
Serial.print(" ");
irrecv.resume(); // receive the next value
}
}
All I did then, was open up the Arduino IED, go to 'Import Library' and then select the IRremote folder.
Then, when I checked the already installed libraries in the IED eg. EEPROM, Esplora, Ethernet, the IRremote library is at the bottom under 'Contributed'.
That's all I did. I assumed the sketch with the code would work when I tried to verify it, but like I said, all I got was errors.
I know little about C, but my sketches have worked ok so far...
In Files|Preferences check the box "Show verbose output during": Compilation
Verify your code again and then scroll back to the top of the output from the compiler/linker/IDE.
If there is a highlighted message like this:
sketch_nov24a.ino:1:20: warning: IRRecv.h: No such file or directory
then the library hasn't been installed in the right place.
Pete
BTW. Stick to the Arduino IDE. The Arduino IED is only for very advanced users.