IR Remote remapping home cinema

Helle there,

I have a samsung tv with a home cinema system from bose. I've been trying to create a code for a arduino to receive IR signals from my samsung remote and convert them to a bose IR output. So far I've not Succeeded ;/ Could anyone help me with making a working code for a arduino uno ?

These are the following IR signals I want to convert from the samsung as input to the bose output:

samsung remote signals:

S_volumeplus = E0E0E01F
S_volumemin = E0E0D02F
S_red = E0E036C9
S_green = E0E028D7
S_yellow = E0E0A857
S_blue = E0E06897

Bose remote signals :

B_volumeplus = 5DD2C03F
B_volumemin = 5DD240BF
B_power = 5DD232CD
B_tv = 5DD2708F
B_aux = 5DD2F00F
B_mute = 5DD2807F

We don't write code for you, but we will help you get your code to work if we can. Read the how to use this forum sticky and post your best attempt code in accordance with the guidelines in the sticky (see #7). A schematic of your circuit will help us, too.

My recommendation is to start with a simple sketch that receives input from your remote and prints the received value to the Serial Monitor. You might find a sketch that does this in the examples that come with the IR remote library, but make sure you take the time to understand what each line of the example code does. This will allow you to verify that you can correctly receive input from the remote.

Next, I would write a simple sketch that outputs a single signal to the Bose once a second. This will allow you to verify that you can correctly output a signal.

Now that you know the hardware is working properly, and have a better understanding of the code required to do this, it should be fairly easy to combine the two programs together with some code that translates between the input and output signals.

Hi Pert,

So far I have a sketch which receives the information from my samsung tv remote, and a sketch which controlls my bose via IF output. But combining those two gave me a lot of problems haha xD I m pretty inexperienced in programming so far but I have already learned a lot :). IF (pun intended :P) someone could take a look at my code and give some advice would be very apprecieted! :smiley:

Files.zip (1.67 KB)

Whenever possible, you should post code directly to the forum. Many of the forum members won't bother to download an attachment, so you are greatly reducing your changes of getting help by doing that. When the code exceeds the forums 9000 character limit, an attachment is a reasonable choice but all three of your sketches combined are still not close to 9000 characters.

You are definitely on the right track with your code, but you didn't take the time to fully understand the IR_READ code before moving on to the next step of combining the code.

In this code in your IR_READ:

Serial.println(results->value, HEX);

You should have read the reference page for Serial.println() to understand it:
https://www.arduino.cc/reference/en/language/functions/communication/serial/println/
The first parameter of Serial.println() is the value to print. In this case, results->value is a number. The second parameter of Serial.println() allows you to define which format the number should be printed in. To your Arduino, a number is just a bunch of 1s and 0s, but humans usually prefer them to be expressed in other forms. We are used to seeing numbers in decimal format, and this is the default format used by Serial.println(). However, in the case of remote codes, hexadecimal format makes sense and so this is why HEX was used for the format parameter.

It's clear you didn't understand the purpose of the second parameter of Serial.println() because it popped up in a very strange place in your attempt to merge the codes:

if ((results.value, HEX)==(S_volumeplus, HEX)) {

As I said before, the Arduino's microcontroller has no need to format numbers in some pretty way for its own purposes. That's something only of use when displaying a number for a human to look at. For this reason, there is no need or facility to specify the format of a number in a comparison. All you needed to do was compare results.value to S_volumeplus, with none of this HEX silliness thrown in to ruin everything.

And here it pops up again used incorrectly in a different context:

irsend.sendNEC((B_volumeplus, HEX), 32);

Now, I'll add an additional bit of advice to make a small non-essential improvement your code. You have multiple if statements, but you know only one will ever be true because results.value will only ever match to one of the Samsung remote codes at a time. In this case, it's best to use if, else if, etc. rather than if, if, etc. The code is more efficient that way because as soon as one of the statements is true, it will skip over the rest. It also makes the code easier to understand. Your current if, if, etc. approach will work, it's just not best practices.

After your advice I wiped everything and started all over again :slight_smile: But now with succes!! Thanks for the help!

My new code:

#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;

void setup()
{
Serial.begin(9600);
Serial.println(“Start IR INPUT”);
irrecv.enableIRIn();
Serial.println(“IR Input Started”);
}

void loop() {

if (irrecv.decode(&results)) {

else if (results.value == 0xE0E0E01F ) { // S_volumeplus
IR_send (0x5DD2C03F);
Serial.println(“S_volumeplus”);
delay(50);
}
else if (results.value == 0xE0E0D02F) { // S_volumemin
IR_send (0x5DD240BF);
Serial.println(“S_volumemin”);
delay(50);
}
else if (results.value == 0xE0E036C9) { // S_red
IR_send (0x5DD232CD);
Serial.println("S_red ");
delay(50);
}
else if (results.value == 0xE0E028D7) { // S_green
IR_send (0x5DD2708F);
Serial.println("S_green ");
delay(50);
}
else if (results.value == 0xE0E0A857) { // S_yellow
IR_send (0x5DD2F00F);
Serial.println("S_yellow ");
delay(50);
}
else if (results.value == 0xE0E06897) { // S_blue
IR_send (0x5DD2807F);
Serial.println("S_blue ");
delay(50);
}

irrecv.enableIRIn();
irrecv.resume(); // Receive the next value
Serial.println(“Receive the next value”);
}
delay(20);
}

void IR_send (long pulse)
{
for (int i = 0; i < 3; i++) {
irsend.sendNEC(pulse, 32);
Serial.println(“Signal send”);
delay(40);
}

}

You're welcome. I'm glad to hear it's working now. Enjoy!
Per