Need Help using MIDI CC to control LEDs

Hi.
I am not a programmer, but I learn fast. I started 2 weeks ago, and already have many things working.
Here is my situation.

I have a Arduino Mini controlling an array of LED's, using FastLED library. This all works perfectly fine.
I am using Hairless to send MIDI from Ableton Live to my Arduino. This works perfectly fine too.

What I am now trying to do is controlling general brightness with PitchBend, and calling effects with ProgramChange, but something must be wrong with my code.
When I delete the ProgramChange part, it works though. But not both at the same time.

Would some of you be kind enough to check it out ?
(I am only posting a small part of it because it has many many lines...)
Thanks already !

  // *** MIDI command interpretation
  { int type, note, velocity, channel, d1, d2, ProgramChange, PitchBend, pitchRange;
    if (MIDI.read()) {                    // Is there a MIDI message incoming ?
      byte type = MIDI.getType();         // What type of message is incoming ?

      if (type = PitchBend) {            // If the type of message is PitchBend, then set the brightness to the value of PitchBend
        d1 = MIDI.getData1();
        d2 = MIDI.getData2();
        channel = MIDI.getChannel();

        {
          FastLED.setBrightness (d2);
        }
      }

      if (type = ProgramChange) {
        d1 = MIDI.getData1();
        d2 = MIDI.getData2();
        channel = MIDI.getChannel();
        {
          if (d1 > 0) {
            currentEffect = (d1);
          }

          else
            currentEffect = 2;
        }
      }
    }
  }

Difficult to tell much from a tiny snippet...but you seem to have created new variables called PitchBend and ProgramChange and not initialised them to any particular values so they will both be 0. Then you compared them to the message type.

Steve

Thanks for the answer. I actually just managed to get it to work like so :

int type, note, velocity, channel, d1, d2, ProgramChange, PitchBend, PitchRange;
  if (MIDI.read()) {                         // Is there a MIDI message incoming ?
    switch (MIDI.getType())                // What type of message is incoming ?
    {
      case midi::PitchBend: {               // If the type of message is PitchBend, then set the brightness to the value of PitchBend
          d1 = MIDI.getData1();
          d2 = MIDI.getData2();
          channel = MIDI.getChannel();
          FastLED.setBrightness (d2);
          break;
        }

      case midi::ProgramChange: {
          d1 = MIDI.getData1();
          d2 = MIDI.getData2();
          channel = MIDI.getChannel();

          if (0 < d1 <= 127) {
            currentEffect = (d1);
          }

          else {
            currentEffect = 0;
          }
          break;
        default:
          break;
        }

    }

  }

The reason that the new version worked better is that using the case statement removed two bugs from your original code.
This

if (type = PitchBend) {

and this

 if (type = ProgramChange) {

are not comparisons, they are assignments - a common error. But even with these two statements fixed you would still have the problem that, as @slipstick pointed out, PitchBend and ProgramChange weren't initialized.

Pete