Lynxo:
My issue is how do you handle the IR when the button is pressed and held down. The NEC protocol sends all F's. Most of these sketches I have seen are for single remote key press. I've been scratching my head as to how to go about making a sketch that will also detect the continued key press on the remote.
Is the first code sent the relevant button code and then it's just FF's after that until button is released? If so then all you need do is remember the last button press that was not FF and if you then get FF just substitute it for the last button press. Something along the lines of
static byte lastValue; // Place to store last value
if (irrecv.decode(&results)) { // Check for IR button press
byte newValue = results.value; // Get IR code
if (newValue == 255) { // NEC repeat button pressed?
newValue = lastValue; // Substitute last not repeat code
}
else { // Not repeat code
lastValue = newValue; // Store last not repeat code
}
switch (newValue) {
case 1:
//do something when var equals 1
break;
case 2:
//do something when var equals 2
break;
default:
// if nothing else matches, do the default
// default is optional
break;
}
irrecv.resume(); // Receive the next value
}