-
|
Hello, I have been working on a project where I have rewired the IR receiver module of an existing device to connect to an arduino, the arduino then filters for certain commands, and consumes them, while repeating all other commands. The repeated commands are to be sent to the existing device through a direct connection. Currently, I am testing the concept between 2 arduino nanos, both running the same code, but I am still struggling to get this concept to work. I'm not sure if I have missed an important
References for this behavior:
https://wolfgang-ziegler.com/blog/faking-ir-signal-with-arduino Here is my code. (note, some of the other includes I have tried, in combination, commented out) (edit: I have adjusted the code to be functional, so that people in the future can use it as a reference) #define USE_NO_SEND_PWM
#define USE_ACTIVE_LOW_OUTPUT_FOR_SEND_PIN
#define IR_RECEIVE_PIN 5
#define IR_SEND_PIN 6
//it's critical for these definitions to be done before the library is included
#include <IRremote.hpp>
void setup()
{
Serial.begin(115200);
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}
void loop() {
if (IrReceiver.decode()) {
//prints for debugging
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX); // Print "old" raw data
IrReceiver.printIRResultShort(&Serial); // Print complete received data in one line
IrReceiver.printIRSendUsage(&Serial); // Print the statement required to send this data
IrSender.sendNEC(IrReceiver.decodedIRData.address, IrReceiver.decodedIRData.command, 3);
Serial.println("Sent NEC signal");
IrReceiver.restartAfterSend();
IrReceiver.resume();
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
During the process of me writing this post, and between 3 days of trial and error/troubleshooting, I found the solution. I figure this is valuable information, so I decided to post it anyways. Here is the solution:
An sidenote, because I was confused with setting up the IrSender instance: I found that if you have |
Beta Was this translation helpful? Give feedback.
During the process of me writing this post, and between 3 days of trial and error/troubleshooting, I found the solution. I figure this is valuable information, so I decided to post it anyways. Here is the solution:
#defines are done before#include <IRremote.hpp>, otherwise they have little/no effect on the library.USE_NO_SEND_PWMandUSE_ACTIVE_LOW_OUTPUT_FOR_SEND_PINAn sidenote, because I was confused with setting up the IrSender instance: I found that if you have
IR_SEND_PINdefined, you don't need to call anyIrSender.begin()or other setup functions.