Controllare il condizionatore tramite il telecomando della tv

Ciao a tutti, vi posto questo sketch nella speranza che possiate suggerirmi quale sia il problema.
In pratica, come da titolo, l’obiettivo sarebbe quello di controllare tramite un telecomando IR un dispositivo differente da quello che è solito comandare.
Nella fattispecie, il telecomando della tv(Codifica RC5) deve comandare il condizonatore(Codifica RAW).
Ho un difetto nel funzionamento, ovvero: quando premo i pulsanti C, PLAY, STOP(che non comandano il condizionatore), il funzionamento è corretto.
Quando premo per la prima volta un pulsante che comanda il condizionatore(MODE, FORWARD, REWIND, BACK, FRONT) il monitor seriale mi stampa la println corrispondente e poi va tutto in blocco, non risponde più ai comandi del telecomando, neppure a C, PLAY, STOP.
Come posso fare per far si che continui l’esecuzione dello sketch? Grazie

#include <IRremote.h>
#include <avr/pgmspace.h>

#define VDIM(v) (sizeof(v)/sizeof((v[0]))

#define C 0x65
#define PLAY 0x59
#define STOP 0x58
#define MODE 0x5A //on
#define FORWARD 0x5C //risc
#define REWIND 0x5B //cond
#define BACK 0x5D //deum
#define FRONT 0x5E //vent

PROGMEM  prog_uint16_t on[]  = {8900,4400,650,1600,650,1650,600,500,650,550,650,500,600,550,600,500,650,1650,650,500,650,1550,700,1600,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,1600,650,550,600,550,600,500,650,500,650,550,600,550,600,1650,600,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,500,650,500,600,550,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,600};

/*21 GRADI*/PROGMEM  prog_uint16_t condmed[]={9000,4400,650,1650,600,1600,650,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,1600,650,1550,700,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,1600,650,500,650,550,650,1550,700,500,600,1650,600,550,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650};
/*29 GRADI*/PROGMEM  prog_uint16_t riscmed[]={9150,4300,750,1500,750,1500,750,350,800,400,750,400,750,400,750,350,800,1550,700,400,750,1500,750,1550,700,450,700,450,700,450,700,400,750,450,700,450,700,400,800,350,800,400,700,400,800,350,800,350,800,400,750,350,800,350,800,400,750,400,750,400,800,350,750,400,750,1500,750,400,750,400,800,350,750,350,850,350,800,350,800,350,650,500,800,350,650,500,650,500,650,550,600,500,650,500,650,550,650,450,650};
PROGMEM  prog_uint16_t deummed[]={9150,4300,750,1500,800,1450,750,350,850,300,850,350,800,350,800,300,800,1500,800,300,850,1450,800,1400,850,350,800,350,850,300,800,350,800,350,800,350,800,350,800,350,800,350,850,300,800,350,850,300,750,400,800,1500,800,1450,750,350,850,300,850,350,800,350,800,300,800,1500,800,350,800,350,750,400,800,350,800,300,800,400,800,300,850,350,800,350,800,350,800,350,750,400,800,350,800,350,750,400,800,350,800};
PROGMEM  prog_uint16_t vent[]={9150,4300,800,1450,800,1450,800,300,850,350,800,350,850,300,800,350,800,1500,800,300,850,1400,800,1450,850,300,850,350,800,300,850,300,800,400,800,1450,800,350,800,350,750,400,800,300,850,350,800,350,800,350,800,350,800,350,800,1450,800,350,800,350,850,300,800,350,800,1500,800,300,850,300,800,350,850,300,850,350,750,400,750,350,800,350,850,350,750,350,850,300,800,400,800,350,750,350,850,350,750,350,800};


unsigned int khz=38;
int RECV_PIN = 11;
int LED_PIN=13;
int statoLed=LOW;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;


void ReadFlash(const uint16_t *x , byte len)
{ unsigned int buffer[100];
  for (byte i=0; i < len; i++) {
    buffer[i] = pgm_read_word( (x+i) );
  }
irsend.sendRaw(buffer, len, khz);
}


void setup()
{
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);  
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    //Serial.println(results.value, HEX);
    switch(results.value) {
     case PLAY:
       //Keyboard.print(" ");
       statoLed=HIGH;
       digitalWrite(LED_PIN, statoLed);
       Serial.println("Lampada accesa");
       delay(50);
       break;
     case STOP:
       //Keyboard.print("s");
       statoLed=LOW;
       digitalWrite(LED_PIN, statoLed);
       Serial.println("Lampada spenta");
       delay(50);
       break;
     case C:
       Serial.println("Chiusura cancello");
       delay(50);
       break;
     case MODE:
          ReadFlash(on, VDIM(on)));
          Serial.println("Accensione condizionatore");
          //delay(50);
          break;
     case FORWARD:          
          ReadFlash(riscmed, VDIM(riscmed)));
          Serial.println("Riscaldamento");
          //delay(50);
          break; 
     case REWIND:          
          ReadFlash(condmed, VDIM(condmed)));
          Serial.println("Condizionamento");
          //delay(50);
          break; 
     case BACK:          
          ReadFlash(deummed, VDIM(deummed)));
          Serial.println("Deumidificazione");
          //delay(50);
          break;  
     case FRONT:          
          ReadFlash(vent, VDIM(vent)));
          Serial.println("Ventilazione");
          //delay(50);
          break; 
     }
    irrecv.resume(); // Receive the next value
  }
}