Hello, Im using arduino nano with IRRemote 4.2.0
I need to receive command from IR, check which protocol is it, store in eeprom and then send with IRsend command.
Code below:
byte protocol=0;
#define IR_SEND_PIN 6
#include <IRremote.hpp>
unsigned long ONButton1;
void setup()
{
IrSender.begin(DISABLE_LED_FEEDBACK);
IrReceiver.begin(2, DISABLE_LED_FEEDBACK);
if (IrReceiver.decode())
{
ONButton = IrReceiver.decodedIRData.decodedRawData;
EEPROM.put(0, ONButton1);
if(IrReceiver.decodedIRData.protocol==NEC)
{
protocol=1;
EEPROM.update(20, protocol);
}
if(IrReceiver.decodedIRData.protocol==SONY)
{
protocol=2;
EEPROM.update(20, protocol);
}
if(IrReceiver.decodedIRData.protocol==RC5)
{
protocol=3;
EEPROM.update(20, protocol);
}
if(IrReceiver.decodedIRData.protocol==RC6)
{
protocol=4;
EEPROM.update(20, protocol);
}
if(IrReceiver.decodedIRData.protocol==SHARP)
{
protocol=8;
EEPROM.update(20, protocol);
}
if(IrReceiver.decodedIRData.protocol==LG)
{
protocol=9;
EEPROM.update(20, protocol);
}
if(IrReceiver.decodedIRData.protocol==SAMSUNG)
{
protocol=10;
EEPROM.update(20, protocol);
}
IrReceiver.resume();
}
}
readEEPROM();
}
void loop()
{
switch (protocol) {
case 1:
IrSender.sendNEC(ONButton1, 32);
break;
case 2:
IrSender.sendSony(ONButton1, 12);
break;
case 3:
IrSender.sendRC5(ONButton1, 12);
break;
case 4:
IrSender.sendRC6(ONButton1, 12);
break;
case 8:
IrSender.sendSharp(ONButton1, 32);
break;
case 9:
IrSender.sendLG(ONButton1, 32);
break;
case 10:
IrSender.sendSAMSUNG(ONButton1, 32);
break;
}
}
problem:
- for example SONY command from receivedump:
IrSender.sendSony(0x1, 0x15, 2, 12); - but when Im learning key and send, then I got:
IrSender.sendSony(0x15, 0x10, 2, 12);
like it changes command with address?
(if I put IrSender.sendSony(0x1, 0x15, 2, 12); instead of IrSender.sendSony(ONButton1, 12); it works perfect, but this command is copied from receivedump example, not from eeprom)
NEC:
- receivedump:
IrSender.sendNEC(0xCD27, 0x0, ); - from arduino:
it works as Onkyo?
IrSender.sendOnkyo(0xFF, 0xE4B3, );
RC5 works OK.
Receiver - 38kHz TSOP34438 or different vishay with 38kHz.
IR diode - L-7104F3BT