Sorry for taking over the thread, but the subject corresponds to my issue... I am trying to create something like "typematic rate" thing for infrared remote, but my delay for the second trigger gets ignored... If I press a button on the remote, I get light turned on and off a lot of times ![]()
This is my interrupt routine:
void getIR() {
detachInterrupt(0); // Not sure if I need to do this, but detaching, just to be sure, we don't get interrupted while in this routine
interrupt_time = millis();
int tempKey = getIRKey(); // Here we get the key number
if ((interrupt_time - last_interrupt_time) < 1000){
presscount++; // counting number of times we get the button press
} else {
presscount = 0; // previous button press was more than a second age, so resetting the counter
}
if (presscount == 1) delay(3000); // this should be done if we get the second command within one second
... different things for every button here ..
last_interrupt_time = interrupt_time; // saving the last interrupt time
attachInterrupt(0, getIR, LOW); // re-attach interrupt 0
}