using 2 IR sensors

I’m having some trouble reading output of both IR sensors on my Uno. It works perfectly when I try to read just the one sensor. But when I replicate the code to read two, both sensors report same output WHEN THEY ARE NOT SUPPOSED TO DO THAT. Here’s my code… wondering if someone can look at it… Thanks. (One sensor attached at pin 10 and other at 11.

#include <IRremote.h>

int RECV_PIN = 10;
int RECV_PIN1 = 11;

IRrecv irrecv(RECV_PIN);
IRrecv irrecv1(RECV_PIN1);

int counter_clock = 0;
int counter_clock1 = 0;

decode_results results;
decode_results results1;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  irrecv1.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    counter_clock = 0;
    Serial.print("At sensor <10>: ");
    Serial.println(results.value);
    irrecv.resume(); // Receive the next value
    delay(25);
  }


 if (irrecv1.decode(&results1)) {
   counter_clock1 = 0;
   Serial.print("At sensor <11>: ");
   Serial.println(results1.value);
   irrecv1.resume(); // Receive the next value
   delay(25);
 }

}

Please use code tags when posting.

WHEN THEY ARE NOT SUPPOSED TO DO THAT

What makes you say that? nothing in your code stops it.

I am saying that because each sensor has a different output. There's an LED on each sensor that tells me when its receiving any IR. So even when one sensor's LED is on and the other's off, both sensors are showing the same output in the serial window.

ALSO, it seems that the sensor I am trying to read at the end of each loop is the one who's output is being displayed for both sensors.

Thanks for inserting code tags.

it seems that the sensor I am trying to read at the end of each loop is the one who’s output is being displayed for both sensors.

Does the library actually support more than one receiver? I am not that familiar with IRremote, as I use IRLib for my IR projects.

Please see the response in the other thread you started.

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

This thread locked.

Other thread: http://forum.arduino.cc/index.php?topic=379473

  • Moderator