title: Clone remote using Arduino with the IRremote library
body: <p>I'm trying to clone an AC remote using Arduino. I read the IR signal using this code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;IRremote.h&gt;
  
  int RECV_PIN = 11;    
  IRrecv irrecv(RECV_PIN);
  decode_results results;
  
  void setup() {
    Serial.begin(9600);
    irrecv.enableIRIn(); // Start the receiver
  }
  
  // Dumps out the decode_results structure.
  // Call this after IRrecv::decode()
  // void * to work around compiler issue
  //void dump(void *v) {
  //  decode_results *results = (decode_results *)v
  void dump(decode_results *results) {
    int count = results-&gt;rawlen;
    if (results-&gt;decode_type == UNKNOWN) {
      Serial.print("Unknown encoding: ");
    } else if (results-&gt;decode_type == NEC) {
      Serial.print("Decoded NEC: ");
    } else if (results-&gt;decode_type == SONY) {
      Serial.print("Decoded SONY: ");
    } else if (results-&gt;decode_type == RC5) {
      Serial.print("Decoded RC5: ");
    } else if (results-&gt;decode_type == RC6) {
      Serial.print("Decoded RC6: ");
    } else if (results-&gt;decode_type == PANASONIC) {   
      Serial.print("Decoded PANASONIC - Address: ");
      Serial.print(results-&gt;panasonicAddress,HEX);
      Serial.print(" Value: ");
    } else if (results-&gt;decode_type == JVC) {
       Serial.print("Decoded JVC: ");
    }
    Serial.print(results-&gt;value, HEX);
    Serial.print(" (");
    Serial.print(results-&gt;bits, DEC);
    Serial.println(" bits)");
    Serial.print("Raw (");
    Serial.print(count, DEC);
    Serial.print("): ");
    for (int i = 0; i &lt; count; i++) {
      if ((i % 2) == 1) {
        Serial.print(results-&gt;rawbuf[i]*USECPERTICK, DEC);
      } else {
        Serial.print(-(int)results-&gt;rawbuf[i]*USECPERTICK, DEC);
      }
      Serial.print(" ");
    }
    Serial.println("");
  }
  
  void loop() {
    if (irrecv.decode(&amp;results)) {
      Serial.println(results.value, HEX);
      dump(&amp;results);
      irrecv.resume(); // Receive the next value
    }
  }
  </code></pre>
  
  <p>And then I use this code to send it to the AC:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;IRremote.h&gt;
  
  IRsend irsend;
  
  void setup() {
  }
  
  void loop() {
    for (int i = 0; i &lt; 3; i++) {
      irsend.sendNEC(0xC64E80C, 32);
      delay(40);
    }
    delay(5000); //5 second delay between each signal burst
  }
  </code></pre>
  
  <p>I use 2 separate Arduinos for testing purposes. But somehow even though the hexa value is the same, the content is not sent in the same way.</p>
  
  <p>The IR signal sent using the remote has 108 values and the IR signal from Arduino has only 68 values.</p>
  
  <p><a href="https://i.stack.imgur.com/7YdPF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7YdPF.jpg" alt="ARDUINO OUTPUT"></a></p>
  
  <p>I tried to change the remote IR LED with my Arduino IR LED and it works just fine. It's not a hardware problem.</p>
  
  <p>Any ideas?</p>