Send signal from IR Led to Receiver (TSOP) on same arduino


#include <Arduino.h>

#include <IRremote.h>

#define IR_RECEIVE_PIN 6

#define IR_SENDER_PIN 3

void setup() {

  Serial.begin(9600);

  IrReceiver.begin(IR_RECEIVE_PIN);

  IrSender.begin(IR_SENDER_PIN);

}

void loop() {

  IrSender.sendSamsung(0x7, 0x7, 0);

  delay(5000);

  if (IrReceiver.decode()) {

    auto &data = IrReceiver.decodedIRData;

    if (data.protocol != UNKNOWN && data.numberOfBits >= 8) {

      IrReceiver.printIRResultShort(&Serial);

      Serial.println("RawData HEX");

      Serial.println(data.decodedRawData, HEX);

      delay(2000); 

    }

    IrReceiver.resume(); 

  }

}


I try to send a signal from an IR led to a receiver on the same arduino. Does this work? What do I have to change? At the moment I dont jump into the IrReceiver.decode() section.

No, especially with that 5s delay :wink:
You need two separate arduinos for what you are looking for.

You need two cores to do what you want. While transmitting the core is busy and cannot receive. A second core could receive while the first is transmitting. This can be accomplished with two Arduino or one with two or more cores.

See Arduino-IRremote/examples/SendAndReceive/SendAndReceive.ino at master · Arduino-IRremote/Arduino-IRremote · GitHub