Several IR receivers on the same Arduino board

Hi all.

This is my first question. I am not engineer, but I’m trying to build a “visitors counter” that tells if the visitors enters or leaves, using IR.

I was using IRremote.h and everything worked great with one receiver. Then I tried 2 and didn’t work. I googled and found on an old thread that reading from two or more receivers was not originally supported, but that the issue was corrected and following a link I ended here: A Multi-Protocol Infrared Remote Library for the Arduino (post from 2010). I tried with the library version I had and with the 2.2.3 that is on that page and still can’t make it work. I prepared a simple sketch just to know if the receivers are working or not. I show it here. What’s wrong? I’m using Arduino Mega, pins 48 and 49. I’m sending the signals with an IR LED connect to another board and sending at 38 kHz.

It sends only NO’s and if I block the receiver on pin 49 sometimes it shows YES for a moment just when I remove the obstable… and the YES appears on the pin 48, which conditions never changed.


#include <IRremote.h>

int IRreceiver_pin48 = 48;
int IRreceiver_pin49 = 49;
IRrecv irrecv48(IRreceiver_pin48);
IRrecv irrecv49(IRreceiver_pin49);
decode_results results;

void setup() {

void loop() {
if (irrecv48.decode(&results)){Serial.print(“YES”);}


if (irrecv49.decode(&results)){Serial.println(“YES”);}