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
#include <IRremote.h>
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
//////////////////Loop
void loop() {
Detect();
if(results.value==16755285)
{
//// run some code in hear
}
delay(1000); // Why does it seem to need this? is it somekind of debounce
}
//////////////////Functions
void Detect(){
irrecv.decode(&results);
irrecv.resume();
}