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);
}
}
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.