IR code mixup help please

I have a sketch that performs perfectly. The project is to simply to provide 6 specific IR remote codes. The sketch displays code and button name on 16X2 LCD. The sketch runs on a nano and displays the hex code is listed in the sketch appears on both the display and the serial monitor. The problem is the hex code of 0xF708FB04 in the sketch actually transmits as 0x20DF10EF. I have tried loading every one of the IRremote libraries with no change. The sketch lists (NEC) as the hex protocol. Could this be the problem? The code is for a Vizio remote control.

Looking for any advice on next steps to troubleshoot this issue.

Thanks
DaveG

Post the sketch.

Why? The OP said it 'works perfectly'.

In which case I wonder why the OP is seeking help!? This is sarcasm because it's tiring to constantly try to help people who don't even provide full information about their problem.

1 Like

Helpers are expected to use crystal balls, do magics.

1 Like

I am amazed that you identified this discrepancy. In my sketches, the hex code in the sketch always matches the output of the Arduino running the sketch.

May I see the sketch you loaded into your Nano? Also, may I know how you checked the transmitted data? Also, for your Visio TV, do you know what IR encoding format it expects?

I was hoping the format may be the problem but I have not been able to find a good explanation or listing of the various encoding schemes. Any advice?

...

Here is the sketch I'm using.
I have the TV remote to compare with and I'm using a simple Arduino, IR sensor and display to read the code.

< #include <IRremote.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Define pins for buttons
#define BUTTON_1 2
#define BUTTON_2 3
#define BUTTON_3 4
#define BUTTON_4 5
#define BUTTON_5 6
#define BUTTON_6 7
#define BUTTON_7 8
#define BUTTON_8 9

// Define the pin for the IR LED
#define IR_LED_PIN 13

// Define 32-bit NEC codes for each button
#define CODE_1 0xF708FB08
#define CODE_2 0xA90B9966
#define CODE_3 0xA90B10EF
#define CODE_4 0xB04FF483
#define CODE_5 0xA90B30CF
#define CODE_6 0xA90B18E7
#define CODE_7 0xA90B7A85
#define CODE_8 0xA90B42BD

// Define button names for LCD display
const char* buttonNames[] = {
  "VIZIO",  // Change Button 1 name to VIZIO
  "Button 2",
  "Button 3",
  "Viewsonic ON",
  "Button 5",
  "Button 6",
  "Button 7",
  "Button 8"
};

// Initialize IR sender
IRsend irSend(IR_LED_PIN);

// Initialize the LCD with I2C address 0x27
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);

  // Initialize buttons as inputs
  pinMode(BUTTON_1, INPUT_PULLUP);
  pinMode(BUTTON_2, INPUT_PULLUP);
  pinMode(BUTTON_3, INPUT_PULLUP);
  pinMode(BUTTON_4, INPUT_PULLUP);
  pinMode(BUTTON_5, INPUT_PULLUP);
  pinMode(BUTTON_6, INPUT_PULLUP);
  pinMode(BUTTON_7, INPUT_PULLUP);
  pinMode(BUTTON_8, INPUT_PULLUP);

  // Initialize the LCD
  lcd.init();
  lcd.backlight();
}

void loop() {
  // Check buttons and send corresponding IR signal
  if (digitalRead(BUTTON_1) == LOW) {
    sendIR(CODE_1, buttonNames[0]);
  } else if (digitalRead(BUTTON_2) == LOW) {
    sendIR(CODE_2, buttonNames[1]);
  } else if (digitalRead(BUTTON_3) == LOW) {
    sendIR(CODE_3, buttonNames[2]);
  } else if (digitalRead(BUTTON_4) == LOW) {
    sendIR(CODE_4, buttonNames[3]);
  } else if (digitalRead(BUTTON_5) == LOW) {
    sendIR(CODE_5, buttonNames[4]);
  } else if (digitalRead(BUTTON_6) == LOW) {
    sendIR(CODE_6, buttonNames[5]);
  } else if (digitalRead(BUTTON_7) == LOW) {
    sendIR(CODE_7, buttonNames[6]);
  } else if (digitalRead(BUTTON_8) == LOW) {
    sendIR(CODE_8, buttonNames[7]);
  }
}

void sendIR(unsigned long code, const char* buttonName) {
  Serial.print("Sending code: ");
  Serial.println(code, HEX);
  irSend.sendNEC(code, 32);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(buttonName);

  lcd.setCursor(0, 1);
  lcd.print("Code: ");
  lcd.print(code, HEX);

  delay(50);  // Adjust delay if necessary
} />

This seems to indicate the NEC protocol. Afaik (Google), Vizio Tvs are made in Taiwan by AmTran, who also makes the JVC brand.

Can you run this sketch? It's an example from the IRRemote library I use. Maybe it can help you narrow down the issue.

/*
 * IRremote: IRremoteInfo - prints relevant config info & settings for IRremote over serial
 * Intended to help identify & troubleshoot the various settings of IRremote
 * For example, sometimes users are unsure of which pin is used for Tx or the RAW_BUFFER_LENGTH value
 * This example can be used to assist the user directly or with support.
 * Intended to help identify & troubleshoot the various settings of IRremote
 * Hopefully this utility will be a useful tool for support & troubleshooting for IRremote
 * Check out the blog post describing the sketch via http://www.analysir.com/blog/2015/11/28/helper-utility-for-troubleshooting-irremote/
 * Version 1.0 November 2015
 * Original Author: AnalysIR - IR software & modules for Makers & Pros, visit http://www.AnalysIR.com
 */
#include <Arduino.h>

//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 240 bytes program memory if IrSender.write is used
//#define SEND_PWM_BY_TIMER
//#define USE_NO_SEND_PWM
//#define NO_LED_FEEDBACK_CODE // saves 566 bytes program memory

#include <IRremote.hpp>

// Function declarations for non Arduino IDE's
void dumpHeader();
void dumpRAW_BUFFER_LENGTH();
void dumpTIMER();
void dumpTimerPin();
void dumpClock();
void dumpPlatform();
void dumpPulseParams();
void dumpSignalParams();
void dumpArduinoIDE();
void dumpDebugMode();
void dumpProtocols();
void dumpFooter();

void setup() {
    Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
    delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
#endif
    // Just to know which program is running on my Arduino
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));

    //Runs only once per restart of the Arduino.
    dumpHeader();
    dumpRAW_BUFFER_LENGTH();
    dumpTIMER();
    dumpTimerPin();
    dumpClock();
    dumpPlatform();
    dumpPulseParams();
    dumpSignalParams();
    dumpArduinoIDE();
    dumpDebugMode();
    dumpProtocols();
    dumpFooter();
}

void loop() {
    //nothing to do!
}

void dumpRAW_BUFFER_LENGTH() {
    Serial.print(F("RAW_BUFFER_LENGTH: "));
    Serial.println(RAW_BUFFER_LENGTH);
}

void dumpTIMER() {
    bool flag = false;
#if defined(IR_USE_TIMER1)
    Serial.print(F("Timer defined for use: "));
    Serial.println(F("Timer1"));
    flag = true;
#endif
#if defined(IR_USE_TIMER2)
    Serial.print(F("Timer defined for use: "));
    Serial.println(F("Timer2"));
    flag = true;
#endif
#if defined(IR_USE_TIMER3)
  Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer3")); flag = true;
#endif
#if defined(IR_USE_TIMER4)
  Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer4")); flag = true;
#endif
#if defined(IR_USE_TIMER5)
  Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer5")); flag = true;
#endif
#if defined(IR_USE_TIMER4_HS)
  Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer4_HS")); flag = true;
#endif
#if defined(IR_USE_TIMER_CMT)
  Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_CMT")); flag = true;
#endif
#if defined(IR_USE_TIMER_TPM1)
  Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_TPM1")); flag = true;
#endif
#if defined(IR_USE_TIMER_TINY0)
  Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_TINY0")); flag = true;
#endif

    if (!flag) {
        Serial.print(F("Timer Error: "));
        Serial.println(F("not defined"));
    }
}

void dumpTimerPin() {
    Serial.print(F("IR Send Pin: "));
#if defined(IR_SEND_PIN)
    Serial.println(IR_SEND_PIN);
#else
    Serial.println(IrSender.sendPin);
#endif
}

void dumpClock() {
#if defined(F_CPU)
    Serial.print(F("MCU Clock: "));
    Serial.println(F_CPU);
#endif
}

void dumpPlatform() {
    Serial.print(F("MCU Platform: "));

#if defined(__AVR_ATmega8__)
  Serial.println(F("Atmega8"));
#elif defined(__AVR_ATmega16__)
    Serial.println(F("ATmega16"));
#elif defined(__AVR_ATmega32__)
  Serial.println(F("ATmega32"));
#elif defined(__AVR_ATmega32U4__)
  Serial.println(F("Arduino Leonardo / Yun / Teensy 1.0 / ATmega32U4"));
#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega48P__)
  Serial.println(F("ATmega48"));
#elif defined(__AVR_ATmega64__)
  Serial.println(F("ATmega64"));
#elif defined(__AVR_ATmega88__) || defined(__AVR_ATmega88P__)
  Serial.println(F("ATmega88"));
#elif defined(__AVR_ATmega162__)
  Serial.println(F("ATmega162"));
#elif defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__)
  Serial.println(F("ATmega164"));
#elif defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) || defined(__AVR_ATmega324PA__)
  Serial.println(F("ATmega324"));

#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__)
  Serial.println(F("ATmega644"));
#elif defined(__AVR_ATmega1280__)
  Serial.println(F("Arduino Mega1280"));
#elif defined(__AVR_ATmega1281__)
  Serial.println(F("ATmega1281"));
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
  Serial.println(F("ATmega1284"));
#elif defined(__AVR_ATmega2560__)
  Serial.println(F("Arduino Mega2560"));
#elif defined(__AVR_ATmega2561__)
  Serial.println(F("ATmega2561"));

#elif defined(__AVR_ATmega8515__)
  Serial.println(F("ATmega8515"));
#elif defined(__AVR_ATmega8535__)
  Serial.println(F("ATmega8535"));

#elif defined(__AVR_AT90USB162__)
  Serial.println(F("Teensy 1.0 / AT90USB162"));
  // Teensy 2.0
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
  Serial.println(F("Teensy 3.0 / Teensy 3.1 / MK20DX128 / MK20DX256"));
#elif defined(__MKL26Z64__)
  Serial.println(F("Teensy-LC / MKL26Z64"));
#elif defined(__AVR_AT90USB646__)
  Serial.println(F("Teensy++ 1.0 / AT90USB646"));
#elif defined(__AVR_AT90USB1286__)
  Serial.println(F("Teensy++ 2.0 / AT90USB1286"));

#elif defined(__AVR_ATtiny84__)
  Serial.println(F("ATtiny84"));
#elif defined(__AVR_ATtiny85__)
  Serial.println(F("ATtiny85"));
#else
    Serial.println(F("ATmega328(P) / (Duemilanove, Diecimila, LilyPad, Mini, Micro, Fio, Nano, etc)"));
#endif
}

void dumpPulseParams() {
    Serial.print(F("Mark Excess: "));
    Serial.print(MARK_EXCESS_MICROS);
    ;
    Serial.println(F(" uSecs"));
    Serial.print(F("Microseconds per tick: "));
    Serial.print(MICROS_PER_TICK);
    ;
    Serial.println(F(" uSecs"));
    Serial.print(F("Measurement tolerance: "));
    Serial.print(TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING);
    Serial.println(F("%"));
}

void dumpSignalParams() {
    Serial.print(F("Minimum Gap between IR Signals: "));
    Serial.print(RECORD_GAP_MICROS);
    Serial.println(F(" uSecs"));
}

void dumpDebugMode() {
    Serial.print(F("Debug Mode: "));
#if DEBUG
  Serial.println(F("ON"));
#else
    Serial.println(F("OFF (Normal)"));
#endif

}

void dumpArduinoIDE() {
    Serial.print(F("Arduino IDE version: "));
    Serial.print(ARDUINO / 10000);
    Serial.write('.');
    Serial.print((ARDUINO % 10000) / 100);
    Serial.write('.');
    Serial.println(ARDUINO % 100);
}

void dumpProtocols() {

    Serial.println();
    Serial.print(F("IR PROTOCOLS  "));
    Serial.print(F("SEND     "));
    Serial.println(F("DECODE"));
    Serial.print(F("============= "));
    Serial.print(F("======== "));
    Serial.println(F("========"));
    Serial.print(F("RC5:          "));
#if defined(DECODE_RC5)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("RC6:          "));
#if defined(DECODE_RC6)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("NEC:          "));
#if defined(DECODE_NEC)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("SONY:         "));
#if defined(DECODE_SONY)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("PANASONIC:    "));
#if defined(DECODE_PANASONIC)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("JVC:          "));
#if defined(DECODE_JVC)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("SAMSUNG:      "));
#if defined(DECODE_SAMSUNG)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("LG:           "));
#if defined(DECODE_LG)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("DENON:        "));
#if defined(DECODE_DENON)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

#if !defined(EXCLUDE_EXOTIC_PROTOCOLS) // saves around 2000 bytes program memory

    Serial.print(F("BOSEWAVE:     "));
#if defined(DECODE_BOSEWAVE)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

    Serial.print(F("WHYNTER:      "));
#if defined(DECODE_WHYNTER)
    Serial.println(F("Enabled"));
#else
    Serial.println(F("Disabled"));
#endif

#endif
}

void printDecodeEnabled(int flag) {
    if (flag) {
        Serial.println(F("Enabled"));
    } else {
        Serial.println(F("Disabled"));
    }
}

void dumpHeader() {
    Serial.println(F("IRremoteInfo - by AnalysIR (http://www.AnalysIR.com/)"));
    Serial.println(
            F(
                    "- A helper sketch to assist in troubleshooting issues with the library by reviewing the settings within the IRremote library"));
    Serial.println(
            F(
                    "- Prints out the important settings within the library, which can be configured to suit the many supported platforms"));
    Serial.println(F("- When seeking on-line support, please post or upload the output of this sketch, where appropriate"));
    Serial.println();
    Serial.println(F("IRremote Library Settings"));
    Serial.println(F("========================="));
}

void dumpFooter() {
    Serial.println();
    Serial.println(F("Notes: "));
    Serial.println(F("- Most of the settings above can be configured in the following files included as part of the library"));
    Serial.println(F("- IRremoteInt.h"));
    Serial.println(F("- IRremote.h"));
    Serial.println(
            F("- You can save SRAM by disabling the Decode or Send features for any protocol (Near the top of IRremoteInt.h)"));
    Serial.println(
            F(
                    "- Some Timer conflicts, with other libraries, can be easily resolved by configuring a different Timer for your platform"));
}

Do not use old exaples with a new library version! Please RTFM.

Sorry ArminJo, I don't understand your response. You may have hit on something but I'm not sure what it is.

This a bit order issue.
0x20DF10EF = 0b0010_0000_1101_1111_0001_0000_1110_1111
0xF708FB04 = 0b1111_0111_0000_1000_1111_1011_0000_0100

IRremote version 2.x used MSB first for the NEC protocol, 3.x and later use LSB first.

What can I do to correct this?

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