Problems with IR emitter + raw codes + progmem

Hi guys,

I'm having a problem when i try to control my air conditioner with an ir emitter.

My raw codes for each button are huge and they took my ram memory in just one singles button so i've tryed to use PROGMEM on my code below but its not working:

#include <IRremote.h>
IRsend irsend;

//const int LED = 13;
//char comando;

void setup()
{
  Serial.begin(9600);
  Serial.println("Setup concluido");
}

String inData;

const unsigned int irTable[2][583] PROGMEM = {
  {508, 356, 508, 360, 504, 364, 508, 356, 508, 360, 508, 25052, 3540, 1664, 504, 1232, 496, 364, 504, 360, 508, 360, 508, 1232, 492, 368, 508, 356, 512, 356, 508, 360, 508, 1232, 492, 364, 512, 1228, 496, 1240, 492, 368, 508, 1228, 496, 1240, 492, 1240, 492, 1240, 492, 1240, 496, 364, 512, 356, 512, 1228, 492, 368, 512, 356, 508, 360, 504, 360, 508, 360, 508, 356, 508, 360, 508, 360, 504, 360, 512, 356, 508, 1228, 496, 364, 508, 1232, 492, 368, 512, 356, 508, 360, 508, 1228, 496, 1236, 496, 368, 508, 356, 508, 360, 512, 356, 508, 1228, 492, 368, 508, 360, 508, 360, 508, 356, 512, 356, 512, 356, 508, 360, 508, 356, 508, 356, 512, 356, 508, 360, 508, 1228, 492, 1244, 492, 1240, 492, 368, 512, 356, 504, 1232, 496, 1240, 492, 1240, 492, 35464, 3540, 1660, 504, 1228, 500, 360, 512, 356, 508, 360, 508, 1228, 496, 364, 512, 356, 508, 360, 508, 356, 516, 1224, 492, 368, 512, 1228, 492, 1240, 496, 364, 512, 1228, 492, 1244, 492, 1236, 496, 1240, 492, 1240, 492, 368, 512, 356, 512, 1224, 496, 368, 508, 356, 508, 360, 500, 368, 500, 368, 496, 368, 500, 368, 496, 368, 500, 368, 500, 364, 500, 368, 500, 1240, 492, 368, 504, 360, 500, 368, 500, 368, 500, 1236, 492, 372, 504, 360, 500, 368, 500, 368, 496, 372, 496, 368, 500, 368, 496, 368, 500, 368, 500, 368, 496, 368, 500, 364, 500, 368, 500, 1240, 492, 368, 508, 356, 500, 368, 500, 368, 500, 368, 500, 1236, 492, 368, 504, 364, 500, 1240, 488, 1244, 492, 368, 508, 35452, 3536, 1664, 508, 1228, 500, 360, 508, 356, 508, 360, 508, 1232, 492, 368, 508, 360, 508, 356, 512, 356, 508, 1232, 492, 368, 508, 1228, 496, 1236, 496, 368, 508, 1228, 496, 1240, 492, 1240, 492, 1240, 496, 1240, 492, 368, 508, 360, 508, 1228, 492, 368, 512, 356, 504, 364, 508, 360, 496, 372, 504, 360, 504, 364, 508, 356, 500, 368, 504, 364, 504, 360, 508, 360, 508, 356, 504, 364, 504, 364, 504, 360, 508, 360, 500, 368, 500, 364, 500, 368, 504, 360, 512, 1224, 492, 1240, 496, 1240, 492, 368, 508, 360, 504, 364, 504, 364, 508, 1224, 496, 368, 500, 368, 500, 1236, 492, 368, 508, 360, 500, 368, 504, 364, 504, 360, 508, 360, 500, 368, 500, 364, 508, 360, 504, 360, 504, 364, 500, 364, 504, 364, 504, 364, 500, 364, 504, 364, 504, 1232, 492, 368, 508, 360, 500, 368, 500, 368, 496, 368, 500, 368, 496, 368, 500, 368, 504, 364, 496, 368, 496, 372, 496, 368, 500, 368, 496, 372, 496, 368, 500, 368, 496, 372, 496, 368, 496, 1240, 496, 1240, 496, 364, 504, 364, 496, 368, 500, 368, 500, 368, 496, 368, 496, 372, 496, 368, 500, 368, 496, 372, 496, 1240, 500, 1232, 504, 356, 508, 360, 500, 368, 496, 368, 500, 368, 500, 368, 496, 368, 500, 368, 496, 368, 500, 368, 500, 368, 496, 368, 500, 368, 496, 368, 500, 368, 500, 364, 500, 368, 500, 1236, 500, 364, 500, 368, 496, 368, 500, 368, 496, 368, 500, 1240, 500, 1232, 500, 360, 500, 368, 500, 368, 496, 368, 500, 368, 500, 364, 500, 368, 500, 1236, 496, 368, 500, 364, 500, 368, 500, 368, 496, 368, 500, 368, 500, 368, 496, 368, 500, 1236, 496, 368, 500, 1236, 496, 368, 496, 1240, 496, 368, 496, 1236, 496, 372, 496}, //liga ar
  {508, 356, 504, 364, 504, 364, 500, 364, 500, 368, 500, 25060, 3540, 1660, 508, 1232, 500, 360, 500, 364, 504, 364, 500, 1240, 500, 360, 504, 360, 508, 360, 504, 364, 504, 1232, 504, 360, 504, 1232, 504, 1232, 496, 364, 508, 1232, 496, 1236, 496, 1236, 496, 1236, 496, 1236, 500, 364, 500, 364, 508, 1232, 500, 360, 504, 364, 504, 364, 508, 356, 508, 360, 504, 360, 508, 360, 508, 360, 508, 356, 504, 364, 504, 1232, 496, 364, 504, 1236, 496, 364, 504, 364, 504, 364, 508, 1228, 496, 1240, 496, 364, 508, 356, 500, 368, 508, 360, 504, 1232, 496, 364, 504, 364, 500, 368, 508, 360, 508, 356, 508, 360, 508, 356, 508, 360, 508, 360, 508, 356, 508, 360, 504, 1232, 496, 1240, 492, 1240, 492, 368, 508, 356, 504, 1236, 496, 1240, 492, 1240, 492, 35456, 3544, 1664, 504, 1228, 504, 356, 504, 364, 504, 360, 512, 1228, 500, 364, 504, 360, 508, 360, 504, 364, 504, 1232, 496, 364, 508, 1232, 492, 1240, 500, 360, 508, 1232, 496, 1236, 496, 1240, 492, 1240, 492, 1240, 496, 364, 508, 360, 508, 1232, 492, 368, 504, 360, 500, 368, 500, 368, 500, 364, 500, 368, 500, 368, 496, 372, 504, 360, 500, 364, 500, 368, 504, 1236, 492, 368, 500, 368, 496, 368, 500, 368, 500, 1236, 496, 368, 496, 368, 500, 368, 500, 368, 496, 368, 504, 364, 500, 368, 496, 368, 504, 364, 500, 364, 500, 368, 500, 368, 496, 372, 500, 1236, 492, 368, 500, 368, 496, 372, 500, 364, 500, 368, 500, 1236, 496, 364, 500, 368, 500, 1236, 496, 1236, 500, 364, 504, 35452, 3544, 1660, 508, 1228, 500, 360, 500, 364, 504, 364, 504, 1236, 504, 356, 504, 364, 504, 360, 504, 364, 500, 1240, 496, 364, 500, 1240, 500, 1232, 500, 360, 504, 1236, 496, 1236, 500, 1232, 504, 1228, 504, 1232, 500, 360, 504, 360, 500, 1240, 500, 360, 500, 368, 500, 368, 508, 360, 504, 360, 504, 3508, 360, 504, 360, 500, 368, 504, 364, 504, 360, 508, 356, 504, 368, 504, 360, 504, 364, 504, 360, 512, 356, 504, 364, 504, 1232, 496, 364, 496, 372, 504, 1232, 500, 1232, 500, 1236, 500, 360, 500, 364, 500, 368, 504, 364, 508, 1228, 504, 356, 500, 368, 504, 1236, 500, 360, 500, 368, 500, 368, 504, 360, 508, 360, 508, 360, 504, 360, 504, 364, 504, 364, 504, 364, 504, 360, 500, 364, 508, 360, 508, 360, 500, 364, 504, 364, 500, 1236, 500, 360, 500, 368, 496, 372, 500, 364, 500, 368, 504, 364, 496, 372, 496, 368, 500, 364, 500, 368, 500, 368, 496, 368, 500, 368, 496, 368, 500, 372, 492, 372, 496, 368, 496, 372, 496, 1240, 504, 1228, 504, 356, 504, 368, 496, 368, 496, 372, 496, 372, 496, 368, 496, 372, 496, 372, 492, 372, 496, 372, 492, 1244, 500, 1232, 500, 360, 500, 368, 496, 372, 496, 368, 500, 368, 496, 372, 496, 368, 496, 372, 496, 368, 500, 368, 496, 372, 496, 368, 496, 372, 496, 372, 496, 368, 496, 372, 496, 368, 500, 1236, 496, 368, 500, 368, 496, 368, 500, 368, 496, 368, 500, 1240, 492, 1240, 492, 368, 500, 368, 496, 372, 496, 368, 500, 368, 496, 368, 500, 368, 496, 1240, 496, 368, 496, 368, 500, 368, 496, 372, 496, 368, 500, 368, 496, 372, 496, 368, 496, 368, 500, 1240, 492, 1240, 496, 368, 496, 1240, 492, 368, 500, 1240, 492, 368, 500} //desliga ar
};

unsigned int irBuf[200];

void sendir(int i) {
  memcpy_P ( irBuf, &irTable[i][0], 583 * 2);
  irsend.sendRaw (irBuf, 583, 38);
}

void loop()
{

  while (Serial.available() > 0)
  {
    char recieved = Serial.read();
    inData += recieved;

    // Processar a mensagem a cada linha recebida
    if (recieved == '\n')
    {

      if (inData == "a\n") {
        sendir(0);
      }
      if (inData == "b\n") {
        sendir(1);
      }

      Serial.print(inData);
      inData = ""; // Limpar buffer recebido
    }
  }
}

Ps: raw codes are double checked

Thank you so much in advanced

You said that you double checked the raw codes. They are different sized (583 vs. 582). Is that correct?

That's an awful lot of Memory usage to define that table. Have you noticed that of the 583 * 2 (= 1166) values, there are only 30 distinct values? In that case, it would be a lot more efficient to use one Array of unsigned int[30] to hold the actual values and redefine your irTable as Byte irTable[2][583]. That cuts the Memory usage for that table in half.

Other than These tips, we really can't help you based on "its not working". Are you getting error codes? What are they? Is it doing something wrong? What? Did the Arduino go up in smoke or start leaking fluids?