can't decode two Infrared remote sensor

hey guys

i tried to decode two ir sensor using this library :

it worked for one sensor but it doesn’t work for two sensor . i used this code

#include <IRremote.h>
int pin1 = 8;
int pin2 = 9;

IRrecv irrecv(pin1);
decode_results results;

IRrecv irrecv2(pin2);
decode_results results2;

void setup()
irrecv.enableIRIn(); // Start the receiver

void loop()
if (irrecv.decode(&results))
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
if (irrecv2.decode(&results2))
Serial.println(results.value, HEX);

here only sensor on pin 9 was working & pin 8 is not working.

what can be the reason ?
Please help guys

if (irrecv2.decode(&results2)) { Serial.println(results.value, HEX); // I have not done this but should this be results2.value ? irrecv2.resume(); }

EDIT: Serial.println(results.value, HEX);

Should be:

Serial.println(results2.value, HEX);


Your two receivers are using the same class and are both trying to use the same timer. You'll need to make a second class that will work with another timer.

but how will i able to make another class for it ?

adarsh-anand: but how will i able to make another class for it ?

Answering that would be a bit beyond the scope of the original question, sorry. There are plenty of articles online covering classes, but you could start by reading and understanding the IRremote library.