# IRreceiver code

**URL:** <https://forum.arduino.cc/t/irreceiver-code/1453440>\
**Category:** Programming\
**Created:** [July 27, 2026, 9:19am UTC](https://forum.arduino.cc/t/irreceiver-code/1453440 "2026-07-27T09:19:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![didu2222](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/didu2222/32/1213549_2.png) [@didu2222](https://forum.arduino.cc/u/didu2222)\
**Post date:** [July 27, 2026, 9:19am UTC](https://forum.arduino.cc/t/irreceiver-code/1453440/1 "2026-07-27T09:19:12Z")

</div>

I am creating an IR remote. So far I managed to write the code for the transmitter.  
It works fine. It is on the latest library.  
My IR Receiver code is on 2.6.0 library. It works fine. I can catch the NEC codes.  
For example my **power off** code is **0x20DF10E** F.  
But when it is rewritten in the latest 4.7.1 version.  
I seem to get false codes like **0xF708FB04**.

Here is the code in version 2.6.0

```arduino
#include <IRremote.h>

const int RECV_PIN = 11; // TSOP34838 OUT pin to Arduino D11
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Ready to receive...");
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value != 0xFFFFFFFF) { // Ignore repeat code
      Serial.print("Code received: 0x");
      Serial.println(results.value, HEX);
    }
    irrecv.resume(); // Receive the next code
  }
}

```

and here is the new version 4.7.1:

```arduino
#include <IRremote.h>
#define USE_IRREMOTE_HPP_AS_PLAIN_INCLUDE
const byte IR_RECEIVE_PIN = 11;

void setup()
{
   Serial.begin(115200);
   Serial.println("IR Receive test");
   IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}

void loop()
{
   if (IrReceiver.decode())
   {   
     auto myRawdata= IrReceiver.printIRResultShort(&Serial);
       Serial.println(myRawdata);
     delay(100); // wait a bit
      IrReceiver.resume();
   }
}

```

I don't know why I am receiving two different codes.  
I want to merge the receiver and transmitter code later.  
The Arduino processor is **ATmega168**  
That is why I am bothering at all.  
I would be thankful if anybody can help.

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [July 27, 2026, 10:55am UTC](https://forum.arduino.cc/t/irreceiver-code/1453440/2 "2026-07-27T10:55:48Z")

</div>

> [@didu2222](#):
>
> I don't know why I am receiving two different codes.

The two codes are not actually different, they are the same NEC frame with the bits in reversed order.

```arduino
0x20DF10EF = 0b00100000110111110001000011101111
0xF708FB04 = 0b11110111000010001111101100000100

```

The old library (2.6.0) printed `results.value` as a human readable MSB first number, while IRremote 4.7.1 stores decodedRawData in the exact bit order the protocol transmits, which is LSB first.

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [July 27, 2026, 9:33pm UTC](https://forum.arduino.cc/t/irreceiver-code/1453440/3 "2026-07-27T21:33:15Z")

</div>

> [@didu2222](#):
>
> So far I managed to write the code for the transmitter.  
> It works fine.

How did you determine it works fine?  
NEC IR commands are transmitted one bit at a time, with each byte sent least-significant bit (LSB) first. Because of this, some IR libraries display the received value exactly as it is transmitted, while others display it in the more familiar hexadecimal byte order.

For example, `0x20DF10EF` and `0xF708FB04` represent the same NEC command. The second value is simply the first with all 32 bits reversed to match the order in which the bits were transmitted. Depending on the IR library you are using, you may see either representation, but they both correspond to the same command.

---

<div class="post-metadata">

**Author:** ![kmin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kmin/32/1147370_2.png) [@kmin](https://forum.arduino.cc/u/kmin)\
**Post date:** [July 27, 2026, 10:11pm UTC](https://forum.arduino.cc/t/irreceiver-code/1453440/4 "2026-07-27T22:11:12Z")

</div>

> [@didu2222](#):
>
> I want to merge the receiver and transmitter code later.

So what's the point of using two library versions that present the signal differently in the first place?
