IR receiver stops sending data to the serial monitor after sending a IR signal

I want to build something that can get a signal and send it back out through some IR LEDs. Currently, I'm stuck on two things. The major thing is that after I send a signal out through my IR LED, the serial monitor stops showing data from the receiver.
I can use a remote to get the IR signals in the serial monitor, click the button that controls whether or not I am sending out IR signals, and suddenly I am no longer able to see the IR receiver serial monitor output.
the other thing is I get data like this "FFA25D" and to send it it needs to be "0xFFA25D"

#include <IRremote.h>
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
IRsend sender;
const int buttonPin = 6;  
const int ledPin = 7;   
int buttonState = 0;  


void setup()
{ /* Initialize sketch */ 
  Serial.begin(9600); // open the serial port at 9600 bps:
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
  digitalWrite(ledPin, LOW);
  irrecv.enableIRIn();
  irrecv.blink13(true);  
}
unsigned long data = 0xFF38C7;
  int len = 32;
void loop ()
{

  if (irrecv.decode(&results)){ // if (irrecv.decode())
Serial.println(results.value, HEX);
//data = (results.value);
irrecv.resume();
  }

//delay(100);

  if (digitalRead(buttonPin) == LOW) {
    //Serial.println("HIGH");
    sender.sendNEC(data, len);
   // irrecv.resume();
    digitalWrite(ledPin, HIGH);
    
  // irrecv.resume();
  } 
  if (digitalRead(buttonPin) == HIGH ) {
    digitalWrite(ledPin, LOW);
   // irrecv.resume();
  }
 // irrecv.resume();


}

alot of this code was Frankensteined together
im using version 2.6 of IRremote GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols

why is this commented out?

because you only want to resume() when you received something, not when you sent something


I'd suggest adopting the latest version of the library IRremote.hpp and the way it does things

ok, didn't notice the irResume() after the receive

looking at the example, does there need to be a call to sender.begin() in setup() before sendNEC() is used?

depends on whether the print formats the output with the "0x" or not

Looks fine to me maybe Update IRremote Library

i was testing to see if i did anything

i tried that, and it half works. it lets me send and still be able to receive ir signals, but their signals are "0" in the serial monitor when I do.

just discovered that verison 3.6 works but it doesn't send anything to the IR LED, i think they changed the pin used for ir in between updates so imma try to find it

The doc is in the GitHub repository

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.