This don't make sense I hook up 3 leds and use IR to read remote works good with

This don’t make sense I hook up 3 leds and use IR to read remote works good with 2 buttons add 3 and it stops.

I Hooked up 3 leds code works fine as long as I’m using just 2 buttons or reading the remote buttons as soon as
I add over 3 the code stops.

Comment led3 out code works

int led1 = 8;
int led2 = 9;
int led3 = 7;
#include <IRLibAll.h>

IRrecv myReceiver(2);//receiver on pin 2
IRdecode myDecoder;//Decoder object

void setup()
{
  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT);
  pinMode (led3, OUTPUT); 
  Serial.begin(9600);
  myReceiver.enableIRIn(); // Start the receiver
}

void loop() {
  if (myReceiver.getResults()) {
    myDecoder.decode();
    if (myDecoder.protocolNum == NEC) {
      switch(myDecoder.value) {
        case 0xFF50AF:  //Volume Down
        Serial.println(F("Volume Down"));
        digitalWrite(led1, !digitalRead(led1));
          break;
        case 0xFFA05F:  //Play/Pause
        Serial.println(F("CH UP"));
        digitalWrite(led2, !digitalRead(led2));
          break;
        case 0xFF7887:  //Volume Up
        Serial.println(F("Volume up"));
        //digitalWrite(led3, !digitalRead(led3)); comment this out code works 
          break;
      }
    myReceiver.enableIRIn(); //Restart the receiver
    }
  }
}

Uncomment led3 code doesn’t run.

int led1 = 8;
int led2 = 9;
int led3 = 7;
#include <IRLibAll.h>

IRrecv myReceiver(2);//receiver on pin 2
IRdecode myDecoder;//Decoder object

void setup()
{
  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT);
  pinMode (led3, OUTPUT); 
  Serial.begin(9600);
  myReceiver.enableIRIn(); // Start the receiver
}

void loop() {
  if (myReceiver.getResults()) {
    myDecoder.decode();
    if (myDecoder.protocolNum == NEC) {
      switch(myDecoder.value) {
        case 0xFF50AF:  //Volume Down
        Serial.println(F("Volume Down"));
        digitalWrite(led1, !digitalRead(led1));
          break;
        case 0xFFA05F:  //Play/Pause
        Serial.println(F("CH UP"));
        digitalWrite(led2, !digitalRead(led2));
          break;
        case 0xFF7887:  //Volume Up
        Serial.println(F("Volume up"));
        digitalWrite(led3, !digitalRead(led3)); uncomment code doesn't run.
          break;
      }
    myReceiver.enableIRIn(); //Restart the receiver
    }
  }
}

Pic shows it reading the 3 buttons.

Screenshot from 2017-11-27 22-14-29.png

Well I'm sorry I can't figure it out code was the same I added comments to post here and guess what.

I removed the led3 comment and got a error ' I back spaced all the way i guess there was a ' there somewhere and it didn't show till i added the comment. LOL

Well Im back the case statement is not working as should. It works sometimes good but then it hangs and don't change states

I think the line

    myReceiver.enableIRIn(); //Restart the receiver

should be outside the

    if (myDecoder.protocolNum == NEC) {

clause.

If your receiver thinks it got something and it is not NEC, it will not be reenabled.

Whandall your right it was in the wrong loop.

I figured it out lol the problem is this

myReceiver.enableIRIn(); //Restart the receiver

It's in the wrong loop lol dang this drove me nut's I read the whole pdf for IRLib2
At about the end I found it the dang thing works for maybe 5 minutes
Then quit's here the working code works great now

myReceiver.enableIRIn(); has to be (myReceiver.getResults()) { loop to keep it reading the remote or it stop's when
It feels like it

My dump truck code Fixed and working good. Thanks Whandall you was dead on it I moved it like 2 times but
wrong way lol.
What get's me is I started with code from Using an Infrared Library on Arduino they had it just like I did the code worked but i think it picks up noise and that shuts it down.

int enablePin = 5;
int in1Pin = 10;
int in2Pin = 11;
int enablePin1 = 6;
int in3Pin = 8;
int in4Pin = 9;
#include "IRLibDecodeBase.h"
#include "IRLibSendBase.h"
#include "IRLib_P01_NEC.h"
#include "IRLibCombo.h"
#include "IRLibRecv.h"
#include "IRLibRecvLoop.h"
#include "IRLibRecvPCI.h"
#include "IRLibFreq.h"
IRrecv myReceiver(2);//receiver on pin 2
IRdecode myDecoder;//Decoder object

void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  pinMode(enablePin1, OUTPUT);
  myReceiver.enableIRIn(); // Start the receiver
}

void loop() {
  if (myReceiver.getResults()) {
    if(myDecoder.decode()){
    if (myDecoder.protocolNum == NEC) {
      switch (myDecoder.value) {
        case 0xFF50AF:  //up
          digitalWrite(in3Pin, LOW);
          digitalWrite(in4Pin, HIGH);
          digitalWrite(enablePin1, HIGH);
          break;
        case 0xFF7887:  //down
          digitalWrite(in3Pin, HIGH);
          digitalWrite(in4Pin, LOW);
          digitalWrite(enablePin1, HIGH);
          break;
       case 0xFFA05F:  //forward 
        digitalWrite(in1Pin,LOW);
        digitalWrite(in2Pin, HIGH);
        digitalWrite(enablePin,HIGH);
          break;
       case 0xFF40BF:  //backward
        digitalWrite(in1Pin,HIGH);
        digitalWrite(in2Pin, LOW);
        digitalWrite(enablePin,HIGH);
          break; 
        case 0xFF02FD:  //backward
        digitalWrite(enablePin1, LOW);
        digitalWrite(enablePin,LOW);
          break; 
      }
      
    }
   }
  myReceiver.enableIRIn(); //Restart the receiver
 }
}