Problem with this code for an IR receiver sketch

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
}
}

I imported the IRremote library,

Where to?
Did you restart the IDE?

Hello. The IRremote library is imported into the Arduino libraries. It's at the bottom of the list.

But each time I try to upload the error messages appear.

Did you restart the IDE?

The IRremote library is imported into the Arduino libraries

Where?

imported into Arduino 1.0.5-r2.

When you open up the IDE again, does that not restart it?

Still no joy.. :confused:

imported into Arduino 1.0.5-r2.

I'll try one more time.

Where?

Okay. I downloaded the IRremote library from the GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols website. It was a zip folder. I renamed it to IRremote as instructed on the website, as it had a big, long name. I opened it.

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.

Thanks. I did that & yes I did get the warning message.

Gonna try & install the library again & see if I've missed out some files...

Well, it works now. I needed to install the IRrecord file into the Arduino library also.

The IR receiver now picks up a signal from a remote and displays it on the serial monitor.