Problems With IR libraries

Hi all , i’m using the IR library by Ken Shirriff. I have it working for the most part but have had a problem. It took me some time to figure out why my code wasn’t working but solved it of a sort by trile and error.
It’s when i perform an if statement to test for a key press on the IR it will only seem to work if there is a delay of at least 1000 directly after the body of the if statement. I based it on a simple example and that did not seem to need this.
I have taken all but the working of what i’m talking about in my example, you can see the delay statement in there. I would be very grateful if some one could tell me were i’m going wrong or tell me why it seems to need it. It also seems that if i drop the delay below 100 it doesn’t work either.
The whole thing would work better if it didn’t do this. Thanks in advance :slight_smile:

#include <IRremote.h>

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
  irrecv.enableIRIn(); // Start the receiver


void loop() {

      //// run some code in hear

       delay(1000); // Why does it seem to need this? is it somekind of debounce


void Detect(){

I've used the library on a couple of projects and you should not need a 1 second delay. I think the problem is with your Detect() function. I think you would do it like this, with resume at the end: if(irrecv.decode(&results) ){ if(results.value==16755285) { //// run some code in hear } irrecv.resume(); } You can look at a project I did (and I use this every day) to turn on my lamp with my TV remote.

I'd like to try the IR library, but the blog page that appears to have the library link is the worst web page I've seen in a long time. IE sends my cpu useage to ~100% and hangs trying to down load and google social networker junk (and probably more). Sometimes the free "blog" sites are almost worse than having no site at all.

Zoomkat: Here's the direct link to the zip file:

Zoomkat: Here's the direct link to the zip file:

Now that works!

Ahh thanks a million for that, it now works how it should :)