Need to debounce an IR signal

I’ve taken this code from a tutorial and with help from this forum I have it working. A problem that I have, however, is that there is much bounce with the push of a button on a TV control. Is there a quick way to debounce the button. I am trying to learn and the debounced version would be used to control some 110 volt appliance. I’ve used PIR to control an appliance and wanted to learn how to do it with IR.
The code is shown below. I hope that you can help.

 * IR Remote: IRrecvDemo
 * demonstrates receiving IR codes with IR recv
 * an IR dectector/demodulatore must be connected to the input RECV_PIN
 * Copyright 2009 Ken Shirriff
 * Version 2.x
   int RECV_PIN = 11;
   IRrecv irrecv(RECV_PIN);
   decode_results results;
  void setup() {
  // put your setup code here, to run once:
  irrecv.enableIRIn();//Start the receiver

void loop() {
  // put your main code here, to run repeatedly:
    irrecv.resume();//Receive the next value

Maybe check out the debounce example in the IDE?

Just keep a note of the last code received and then only react to something different, setting the last code received .

if(last != current){ 
 last = current;
 lasttime = millis();
} else {
 heldtime = millis() - lasttime;
 if (heldtime % 20 == 0){ Serial.print(heldtime);}
// is % right for MOD, I forget.
if (millis() - lasttime > 100){
 last = blank;


Obviously you could improve on that by also having a timed clearing process in case you do not catch the button up events.

Otherwise if you press 1, turn the remote away and release the button, then turn back and press 1 again, you may not process it.

Thru the repeated code you could calculate heldtime and act accordingly.

Your code is already only checking the IR device 10 times a second. It is hard to believe that the IR transmitter is sending the same code more than once every tenth of a second. Most IR transmitters send a code when a key becomes pressed, and a different code (meaning repeat the previous action) when the key is held down.