sendRaw not working for some

Hello everybody, I'm working on a project to make myself a tv remote that I can use easier. I have all but two functions working and I'm about to pull my hair out trying to figure out why. Below is my code and the two functions I can't get to work is the one associated with the "e" (enter on the remote) and the one associated with "right". When I decode the remote for a few functions, I get an unknown protocol so that's why I am using the sendRaw function on some. Any help would be great appreciated!!

#include <Arduino.h>

#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>

void setup() {
    Serial.begin(115200);
    IrSender.begin(); // Start with IR_SEND_PIN as send pin and if NO_LED_FEEDBACK_CODE is NOT defined, enable feedback LED at default feedback LED pin
}
String a;
int sRepeats = 0;
void loop() {
  if (Serial.available()>0)  {
    a = Serial.readString();

    if(a=="p") {
    IrSender.sendNEC(0x707, 0x2, sRepeats);
    }
    if(a=="up") {
      IrSender.sendNEC(0x707, 0x60, sRepeats);
    }
    if(a=="down") {
      IrSender.sendNEC(0x707, 0x61, sRepeats);
    }
    }
    if(a=="s") {  
      IrSender.sendNEC(0x707, 0x1, sRepeats);
    }
    if(a=="vd") {  
unsigned int vdown[68]={4600,4350,700,1550,650,1550,700,1500,700,450,650,450,700,400,700,400,700,400,700,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1500,700,450,650,1550,700,400,700,400,700,450,700,400,700,400,700,400,700,1550,700,400,700,1500,700,1500,700,1550,700,1500,700};
      IrSender.sendRaw(vdown, 68,38);
    }
    if(a=="vu") {  
const unsigned int vup[68]={4600,4350,650,1550,700,1500,700,1550,700,400,700,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,400,700,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,400,700,450,700,400,700,400,700,400,700,450,650,450,650,450,650,1550,700,1500,700,1550,700,1500,700,1550,650};
      IrSender.sendRaw(vup, 68,38);
    }
    if(a=="vm") {  
const unsigned int vm[68]={4650,4350,650,1550,650,1550,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1500,700,1550,700,400,700,450,650,400,700,450,700,400,700,1500,700,1550,650,1550,700,1500,700,450,700,400,700,400,700,400,700,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,1500,700};
      IrSender.sendRaw(vm, 68,38);
    }
    if(a=="left") {  
const unsigned int left[71] = {4530,4520, 530,1720, 530,1720, 530,1720, 580,570, 530,570, 580,570, 530,570, 580,570, 580,1670, 580,1670, 580,1670, 580,570, 530,570, 580,570, 530,570, 530,620, 530,1720, 530,570, 580,1670, 580,570, 530,570, 580,1670, 580,1670, 530,620, 230,220, 130,520, 580,1670, 580,570, 530,1720, 530,1720, 530,570, 280,220, 130,520, 580,1670, 580};  // Protocol=UNKNOWN Hash=0x21D904E 36 bits (incl. gap and start) received
      IrSender.sendRaw(left, 71,38);
    }
    if(a=="right") {  
const unsigned rt[109] = {180,220, 4130,4520, 180,220, 180,1670, 130,220, 180,1720, 180,220, 180,1670, 130,270, 130,620, 180,920, 130,270, 130,620, 180,920, 130,270, 130,620, 230,1970, 180,220, 180,1670, 230,2020, 180,220, 180,620, 180,870, 180,220, 180,670, 180,820, 180,220, 180,570, 230,870, 180,220, 180,1670, 180,220, 180,620, 230,820, 180,970, 180,220, 130,1720, 180,220, 130,1720, 180,220, 130,670, 180,2020, 130,220, 180,670, 180,1970, 180,220, 130,1720, 180,220, 180,1670, 180,920, 180,220, 180,670, 130,2020, 180,220, 180}; 
      IrSender.sendRaw(rt, 109,38);
    }
    if(a=="e") {
const unsigned select[9] = {180,770, 130,770, 180,770, 180,720, 230};
      IrSender.sendRaw(select,9,38);
    }
    delay(100);  // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
}

It is normal for the code to start with a long pulse. I see that the raw codes that work start with "{4xxx,4xxx,":

vdown[68]= {4600,4350, 700,1550, 650,1550, 
vup[68]={4600,4350, 650,1550, 700,1500,700, 
vm[68]={4650,4350, 650,1550, 650,1550, 
left[71] = {4530,4520, 530,1720, 530,1720,

But the two that don't work, don't start with two values in the 4000 range.:

rt[109] = {180,220, 4130,4520, 180,220, 
select[9] = {180,770, 130,770, 180,770,

I think you need to re-capture those codes.

Thank you, that did the job. Another question though. I need to setup a LCD screen with an I2C converter. Everything I read says I have to use port 3 for the IR emitter but also have to use port 3 for the screen. I'm using an Arduino Leonardo. Have I run into a brick wall?

I found a software I2C library that allows you to specify ports.

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