[Solved] Need Help With Existing Bypass IR Receiver codes

im Doing the same as this older user but the treat is kinda dead. so i hope someone can still help. im trying to bypass the ir receiver of an HDMI Switch but i cant get te right code out of the program i dont get how he set the hex to send able code.

// pulse parameters in usec
#define HDR_MARK  9000
#define HDR_SPACE 4500
#define BIT_MARK  560
#define ONE_SPACE 1690
#define ZERO_SPACE  560

#define TOPBIT 0x80000000

const int OutputPin = 11;

void send() {
  Serial.println("Sending");
  mark(HDR_MARK);
  space(HDR_SPACE);


  for (int i = 0; i < 4; i++) {
    mark(BIT_MARK);
    space(ZERO_SPACE);
  }
  for (int i = 0; i < 8; i++) {
    mark(BIT_MARK);
    space(ONE_SPACE);
  }
  for (int i = 0; i < 6; i++) {
    mark(BIT_MARK);
    space(ZERO_SPACE);
  }
  for (int i = 0; i < 1; i++) {
    mark(BIT_MARK);
    space(ONE_SPACE);
  }
  for (int i = 0; i < 1; i++) {
    mark(BIT_MARK);
    space(ZERO_SPACE);
  }
  for (int i = 0; i < 7; i++) {
    mark(BIT_MARK);
    space(ONE_SPACE);
  }
  mark(BIT_MARK);
  space(0);
}

void mark(int time) {
  digitalWrite(OutputPin, LOW);
  delayMicroseconds(time);
}

void space(int time) {
  digitalWrite(OutputPin, HIGH);
  delayMicroseconds(time);
}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(OutputPin, OUTPUT);
  digitalWrite(OutputPin, HIGH);


}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) {
    char inChar = Serial.read();
    if (inChar == '!' ) {
      //digitalWrite(OutputPin, HIGH);
      send();
      //digitalWrite(OutputPin, LOW);
    }
  }
}

the code that the IR receiver gets is now FF02FF but i dont get how to change it to get following codes

Channel1 = FF906F
Channel2 = FFE01F
Channel3 = FF02FD

the original post is:

Hope anyone can help.

The original code has the value “0FF02FF” hard coded into a bunch of loops. Replacing the loops with function calls makes the design a little clearer:

// pulse parameters in usec
#define HDR_MARK  9000
#define HDR_SPACE 4500
#define BIT_MARK  560
#define ONE_SPACE 1690
#define ZERO_SPACE  560

#define TOPBIT 0x80000000

const int OutputPin = 11;

void sendOnes(byte count)
{
  for (int i = 0; i < count; i++)
  {
    mark(BIT_MARK);
    space(ONE_SPACE);
  }
}

void sendZeroes(byte count)
{
  for (int i = 0; i < count; i++)
  {
    mark(BIT_MARK);
    space(ZERO_SPACE);
  }
}

// Send 0FF02FF (28 bits)
void send0FF02FF()
{
  Serial.println("Sending");

  // Header
  mark(HDR_MARK);
  space(HDR_SPACE);

  // 0000  (0x0)
  sendZeroes(4);

  // 11111111 (0xFF)
  sendOnes(8);

  // 00000010 (0x02)
  sendZeroes(6);
  sendOnes(1);
  sendZeroes(1);

  // 11111111 (0xFF)
  sendOnes(8);
}

void mark(int time)
{
  digitalWrite(OutputPin, LOW);
  delayMicroseconds(time);
}

void space(int time)
{
  digitalWrite(OutputPin, HIGH);
  delayMicroseconds(time);
}


void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(OutputPin, OUTPUT);
  digitalWrite(OutputPin, HIGH);
}

void loop()
{
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0)
  {
    char inChar = Serial.read();
    if (inChar == '!' )
    {
      //digitalWrite(OutputPin, HIGH);
      send0FF02FF();
      //digitalWrite(OutputPin, LOW);
    }
  }
}

This Makes So much more sense thank u very much!

if i send the code to my other arduino (programmed to read IR receiver) only gets FF0 so is there something i’m doing wrong or?

the code i use to read the receiver is the standard IRremote receive code.

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

Use the IRrecvDumpV2 example and let me know what it says. Just showing the raw bits doesn't say much about the data format.

i changed the hex to the code send by the remote from FF02FF to FF02FD

when i use the IRrecvDemoV2 i get this for the code send (FF02FD)

Arduino send:

Encoding  : JVC
Code      : FF0 (16 bits)
Timing[57]: 
     +9050, -4500     + 550, - 550     + 550, - 600     + 550, - 550
     + 550, - 600     + 550, -1700     + 550, -1700     + 550, -1700
     + 550, -1700     + 550, -1700     + 550, -1700     + 550, -1700
     + 550, -1700     + 550, - 600     + 550, - 550     + 550, - 600
     + 550, - 550     + 550, - 600     + 550, - 550     + 600, -1650
     + 600, - 550     + 550, -1700     + 550, -1700     + 550, -1700
     + 550, -1700     + 550, -1700     + 550, -1700     + 550, - 600
     + 550
unsigned int  rawData[57] = {9050,4500, 550,550, 550,600, 550,550, 550,600, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,600, 550,550, 550,600, 550,550, 550,600, 550,550, 600,1650, 600,550, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,600, 550};  // JVC FF0
unsigned int  data = 0xFF0;

Original code by remote true IR receiver:

Remote:
Encoding  : NEC
Code      : FF02FD (32 bits)
Timing[67]: 
     +10300, -4450     + 750, - 500     + 700, - 500     + 650, - 550
     + 700, - 500     + 700, - 500     + 700, - 500     + 700, - 550
     + 650, - 550     + 700, -1600     + 700, -1600     + 700, -1600
     + 700, -1600     + 700, -1600     + 700, -1600     + 700, -1650
     + 650, -1650     + 650, - 550     + 700, - 500     + 700, - 500
     + 700, - 550     + 650, - 550     + 650, - 550     + 700, -1600
     + 700, - 550     + 600, -1700     + 650, -1650     + 600, -1700
     + 600, -1700     + 600, -1700     + 700, -1600     + 650, - 600
     + 600, -1700     + 600
unsigned int  rawData[67] = {10300,4450, 750,500, 700,500, 650,550, 700,500, 700,500, 700,500, 700,550, 650,550, 700,1600, 700,1600, 700,1600, 700,1600, 700,1600, 700,1600, 700,1650, 650,1650, 650,550, 700,500, 700,500, 700,550, 650,550, 650,550, 700,1600, 700,550, 600,1700, 650,1650, 600,1700, 600,1700, 600,1700, 700,1600, 650,600, 600,1700, 600};  // NEC FF02FD
unsigned int  data = 0xFF02FD;

One problem I see is that the remote is detected as NEC protocol (32 bit) but the simulation is detected as JVC (16 bit). Part of the problem is that the remote seems to use a MARK pulse of 650-700 uS and the simulation uses 560. The ZERO SPACE pulse seems to be OK at 550.

ok i'll try to change the mark pulse but it still seems strange to my why the simulation wouldn't be giving the code i made than.

Still The Hex isn't changing. i've tried to change the Bit mark and than tried the Zero Space to 550 because you spoke of 550 and its 560 in the program.

Bit mark 700, Zero Space 560.

Encoding  : JVC
Code      : FF0 (16 bits)
Timing[57]: 
     +9050, -4450     + 700, - 600     + 700, - 550     + 700, - 550
     + 700, - 600     + 700, -1700     + 700, -1650     + 700, -1700
     + 700, -1700     + 700, -1700     + 700, -1700     + 700, -1700
     + 700, -1650     + 750, - 550     + 700, - 550     + 700, - 550
     + 700, - 600     + 700, - 550     + 700, - 550     + 700, -1700
     + 700, - 600     + 700, -1650     + 700, -1700     + 700, -1700
     + 700, -1700     + 700, -1700     + 700, -1700     + 700, - 550
     + 700
unsigned int  rawData[57] = {9050,4450, 700,600, 700,550, 700,550, 700,600, 700,1700, 700,1650, 700,1700, 700,1700, 700,1700, 700,1700, 700,1700, 700,1650, 750,550, 700,550, 700,550, 700,600, 700,550, 700,550, 700,1700, 700,600, 700,1650, 700,1700, 700,1700, 700,1700, 700,1700, 700,1700, 700,550, 700};  // JVC FF0
unsigned int  data = 0xFF0;

Bit mark 650, Zero Space 560.

Encoding  : JVC
Code      : FF0 (16 bits)
Timing[57]: 
     +9000, -4500     + 650, - 550     + 650, - 600     + 650, - 550
     + 650, - 550     + 650, -1700     + 650, -1700     + 650, -1700
     + 650, -1700     + 650, -1700     + 650, -1650     + 650, -1700
     + 650, -1700     + 650, - 550     + 650, - 600     + 650, - 550
     + 650, - 550     + 650, - 600     + 650, - 550     + 650, -1700
     + 650, - 550     + 650, -1700     + 650, -1700     + 650, -1700
     + 650, -1700     + 650, -1650     + 650, -1700     + 650, - 600
     + 650
unsigned int  rawData[57] = {9000,4500, 650,550, 650,600, 650,550, 650,550, 650,1700, 650,1700, 650,1700, 650,1700, 650,1700, 650,1650, 650,1700, 650,1700, 650,550, 650,600, 650,550, 650,550, 650,600, 650,550, 650,1700, 650,550, 650,1700, 650,1700, 650,1700, 650,1700, 650,1650, 650,1700, 650,600, 650};  // JVC FF0
unsigned int  data = 0xFF0;

Bit mark 650, Zero Space 550.

Encoding  : JVC
Code      : FF0 (16 bits)
Timing[57]: 
     +9050, -4450     + 650, - 600     + 650, - 550     + 650, - 550
     + 650, - 550     + 650, -1700     + 650, -1700     + 650, -1650
     + 650, -1700     + 650, -1700     + 650, -1700     + 650, -1700
     + 650, -1700     + 650, - 550     + 650, - 550     + 650, - 550
     + 650, - 550     + 650, - 550     + 650, - 550     + 650, -1700
     + 650, - 550     + 650, -1700     + 650, -1700     + 650, -1700
     + 650, -1700     + 650, -1700     + 650, -1650     + 650, - 600
     + 650
unsigned int  rawData[57] = {9050,4450, 650,600, 650,550, 650,550, 650,550, 650,1700, 650,1700, 650,1650, 650,1700, 650,1700, 650,1700, 650,1700, 650,1700, 650,550, 650,550, 650,550, 650,550, 650,550, 650,550, 650,1700, 650,550, 650,1700, 650,1700, 650,1700, 650,1700, 650,1700, 650,1650, 650,600, 650};  // JVC FF0
unsigned int  data = 0xFF0;

Bit mark 700, Zero Space 550.

Encoding  : JVC
Code      : FF0 (16 bits)
Timing[57]: 
     +9050, -4500     + 700, - 550     + 700, - 550     + 700, - 550
     + 700, - 550     + 700, -1700     + 700, -1700     + 700, -1700
     + 700, -1650     + 750, -1650     + 700, -1700     + 700, -1700
     + 700, -1700     + 700, - 550     + 700, - 550     + 700, - 550
     + 700, - 550     + 700, - 550     + 750, - 550     + 700, -1700
     + 650, - 600     + 700, -1650     + 750, -1650     + 700, -1700
     + 700, -1700     + 700, -1700     + 700, -1700     + 700, - 550
     + 700
unsigned int  rawData[57] = {9050,4500, 700,550, 700,550, 700,550, 700,550, 700,1700, 700,1700, 700,1700, 700,1650, 750,1650, 700,1700, 700,1700, 700,1700, 700,550, 700,550, 700,550, 700,550, 700,550, 750,550, 700,1700, 650,600, 700,1650, 750,1650, 700,1700, 700,1700, 700,1700, 700,1700, 700,550, 700};  // JVC FF0
unsigned int  data = 0xFF0;

I wonder if it is the number of pulses that is causing the signal to be recognized as JVC rather than NEC. The signal from the actual remote translates to:

0000 0000 1111 1111 0000 0010 1111 1101
0x00FF02FD

Looks like there are four zeroes missing at the front of the code. Try this:

  // 0000 0000  (0x00)
  sendZeroes(8);

  // 1111 1111 (0xFF)
  sendOnes(8);

  // 0000 0010 (0x02)
  sendZeroes(6);
  sendOnes(1);
  sendZeroes(1);

  // 1111 1101 (0xFD)
  sendOnes(6);
  sendZeroes(1);
  sendOnes(1);

its getting closer!

the last key is missing at the moment maybe there is an ending key too?

this is what i get now with Bit_Mark 700 and Zero Space 550. the D is missing and it says 28bit while it needs to be 32bit. i think.

Encoding  : LG
Code      : FF02F (28 bits)
Timing[65]: 
     +9050, -4450     + 700, - 600     + 700, - 550     + 700, - 550
     + 700, - 550     + 700, - 550     + 700, - 550     + 700, - 550
     + 700, - 550     + 700, -1700     + 700, -1700     + 700, -1700
     + 700, -1700     + 700, -1650     + 750, -1650     + 700, -1700
     + 700, -1700     + 700, - 550     + 700, - 550     + 700, - 550
     + 700, - 550     + 750, - 550     + 700, - 550     + 700, -1700
     + 700, - 550     + 700, -1650     + 750, -1650     + 700, -1700
     + 700, -1700     + 700, -1700     + 700, -1700     + 700, - 550
     + 700
unsigned int  rawData[65] = {9050,4450, 700,600, 700,550, 700,550, 700,550, 700,550, 700,550, 700,550, 700,550, 700,1700, 700,1700, 700,1700, 700,1700, 700,1650, 750,1650, 700,1700, 700,1700, 700,550, 700,550, 700,550, 700,550, 750,550, 700,550, 700,1700, 700,550, 700,1650, 750,1650, 700,1700, 700,1700, 700,1700, 700,1700, 700,550, 700};  // LG FF02F
unsigned int  data = 0xFF02F;

According to references, the proper NEC timing is:

#define HDR_MARK  9000
#define HDR_SPACE 4500
#define BIT_MARK  560
#define ONE_SPACE (2250-BIT_MARK)
#define ZERO_SPACE  (1125-BIT_MARK)

It also appears that an additional BIT_MARK at the end is needed to clock in the last bit.

  // 0000 0000  (0x00)  Address
  sendZeroes(8);

  // 1111 1111 (0xFF)  Address Inverted
  sendOnes(8);

  // 0000 0010 (0x02) Command
  sendZeroes(6);
  sendOnes(1);
  sendZeroes(1);

  // 1111 1101 (0xFD) Command Inverted
  sendOnes(6);
  sendZeroes(1);
  sendOnes(1);

  // Closing MARK
  mark(BIT_MARK);
  // Idle in space() state
  space(1);

So now the code is messed up more than before. i just replased the marks and spaces. here is the code.

// pulse parameters in usec

#define HDR_MARK  9000
#define HDR_SPACE 4500
#define BIT_MARK  560
#define ONE_SPACE (2250-BIT_MARK)
#define ZERO_SPACE  (1125-BIT_MARK)

#define TOPBIT 0x80000000

const int OutputPin = 11;

void sendOnes(byte count)
{
  for (int i = 0; i < count; i++)
  {
    mark(BIT_MARK);
    space(ONE_SPACE);
  }
}

void sendZeroes(byte count)
{
  for (int i = 0; i < count; i++)
  {
    mark(BIT_MARK);
    space(ZERO_SPACE);
  }
}

// Send 0FF02FF (28 bits)
void send0FF02FD()
{
  Serial.println("Sending");

  // 0000 0000  (0x00)  Address
  sendZeroes(8);

  // 1111 1111 (0xFF)  Address Inverted
  sendOnes(8);

  // 0000 0010 (0x02) Command
  sendZeroes(6);
  sendOnes(1);
  sendZeroes(1);

  // 1111 1101 (0xFD) Command Inverted
  sendOnes(6);
  sendZeroes(1);
  sendOnes(1);

  // Closing MARK
  mark(BIT_MARK);
  // Idle in space() state
  space(1);
  }

void mark(int time)
{
  digitalWrite(OutputPin, LOW);
  delayMicroseconds(time);
}

void space(int time)
{
  digitalWrite(OutputPin, HIGH);
  delayMicroseconds(time);
}


void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(OutputPin, OUTPUT);
  digitalWrite(OutputPin, HIGH);
}

void loop()
{
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0)
  {
    char inChar = Serial.read();
    if (inChar == '!' )
    {
      //digitalWrite(OutputPin, HIGH);
      send0FF02FD();
      //digitalWrite(OutputPin, LOW);
    }
  }
}

and here is the latest code i get. its now changed to 20D93043. here is the latest code:

Encoding  : UNKNOWN
Code      : 20D93043 (32 bits)
Timing[65]: 
     + 550, - 550     + 600, - 550     + 550, - 600     + 550, - 600
     + 550, - 550     + 600, - 550     + 600, - 550     + 550, - 550
     + 600, -1650     + 600, -1700     + 550, -1700     + 550, -1700
     + 550, -1700     + 550, -1700     + 550, -1700     + 550, -1700
     + 550, - 550     + 600, - 550     + 550, - 550     + 600, - 550
     + 550, - 600     + 550, - 550     + 600, -1650     + 600, - 550
     + 550, -1700     + 550, -1700     + 550, -1700     + 550, -1700
     + 550, -1700     + 550, -1700     + 550, - 600     + 550, -1700
     + 550
unsigned int  rawData[65] = {550,550, 600,550, 550,600, 550,600, 550,550, 600,550, 600,550, 550,550, 600,1650, 600,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,550, 600,550, 550,550, 600,550, 550,600, 550,550, 600,1650, 600,550, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,1700, 550,600, 550,1700, 550};  // UNKNOWN 20D93043

You accidentally removed the sending of the header. Put them back in! :slight_smile:

1 Like

you gotta be kidding me :sweat_smile: yes that was it! now that the code are sendable i can begin to take the HDMI switch apart. thank u very much for your time! I’ve tried the other codes and they work too now i just hope the chip of my switch will understand it too.

thanks again and have a good one!

and if anyone will find this and needs the code:

// pulse parameters in usec

#define HDR_MARK  9000
#define HDR_SPACE 4500
#define BIT_MARK  560
#define ONE_SPACE (2250-BIT_MARK)
#define ZERO_SPACE  (1125-BIT_MARK)

#define TOPBIT 0x80000000

const int OutputPin = 11;

void sendOnes(byte count)
{
  for (int i = 0; i < count; i++)
  {
    mark(BIT_MARK);
    space(ONE_SPACE);
  }
}

void sendZeroes(byte count)
{
  for (int i = 0; i < count; i++)
  {
    mark(BIT_MARK);
    space(ZERO_SPACE);
  }
}

// Send 0FF02FF (28 bits)
void send0FF02FD()
{
  Serial.println("Sending");

  // Header
  mark(HDR_MARK);
  space(HDR_SPACE);

  // 0000 0000  (0x00)  Address
  sendZeroes(8);

  // 1111 1111 (0xFF)  Address Inverted
  sendOnes(8);

  // 0000 0010 (0x02) Command
  sendZeroes(6);
  sendOnes(1);
  sendZeroes(1);

  // 1111 1101 (0xFD) Command Inverted
  sendOnes(6);
  sendZeroes(1);
  sendOnes(1);

  // Closing MARK
  mark(BIT_MARK);
  // Idle in space() state
  space(1);
}

void send0FF906F()
{
  Serial.println("Sending");

  // Header
  mark(HDR_MARK);
  space(HDR_SPACE);

  // 0000 0000  (0x00)  Address
  sendZeroes(8);

  // 1111 1111 (0xFF)  Address Inverted
  sendOnes(8);

  // 1001 0000 (0x90) Command
  sendOnes(1);
  sendZeroes(2);
  sendOnes(1);
  sendZeroes(4);

  // 0110 1111 (0x6F) Command Inverted
  sendZeroes(1);
  sendOnes(2);
  sendZeroes(1);
  sendOnes(4);

  // Closing MARK
  mark(BIT_MARK);
  // Idle in space() state
  space(1);
}

void send0FFE01F()
{
  Serial.println("Sending");

  // Header
  mark(HDR_MARK);
  space(HDR_SPACE);

  // 0000 0000  (0x00)  Address
  sendZeroes(8);

  // 1111 1111 (0xFF)  Address Inverted
  sendOnes(8);

  // 1110 0000 (0xE0) Command
  sendOnes(3);
  sendZeroes(5);

  // 0001 1111 (0x1F) Command Inverted
  sendZeroes(3);
  sendOnes(5);

  // Closing MARK
  mark(BIT_MARK);
  // Idle in space() state
  space(1);
}

void mark(int time)
{
  digitalWrite(OutputPin, LOW);
  delayMicroseconds(time);
}

void space(int time)
{
  digitalWrite(OutputPin, HIGH);
  delayMicroseconds(time);
}


void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(OutputPin, OUTPUT);
  digitalWrite(OutputPin, HIGH);
}

void loop()
{
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0)
  {
    char inChar = Serial.read();
    if (inChar == '!' )
    {
      //digitalWrite(OutputPin, HIGH);
      send0FF02FD();
      //digitalWrite(OutputPin, LOW);
    }
  }
  
  // For testing the codes wuthout the press of a button.
  /*
  send0FF02FD();
  delay(1000);
  send0FF906F();
  delay(1000);
  send0FFE01F();
  delay(1000);
  */
}
1 Like

So i tried it on the HDMI switch and it works beautifully :slight_smile:




I connected the yellow wire to the communication port and the black wire to the ground port where the IR receiver was. dont forget to always make sure that the ground is always connected somehow. you cant make to many safety connections. like always check every detail of the board. In my case (and almost every case) the IR receiver gives a 3.3V signal, so dont forget to check that or the IC you're communicating with is capable of the voltage you're using or like in my case the IC was fully powered on 3.3V so i couldn't use 5V port directly, so therefor i used a voltage divider circuit. like this one:

So Big thanks to johnwasser for helping out!