Trouble Fading LEDs from 255 to anyting other then off (code inside)

So I am creating an installation controlled by an X Band Sensor that triggers a group of LEDs to pulse when a body enters a space. I can get them to pulse no problem but I can’t figure out how to get the LEDs to end the pulse anything other then 0 after the pulse. Basically I want the pulse that occurs to have some low brightness after the bright portion of the animation that rolls over to the next pulse triggered by the sensor. Been working for hours and am not sure where to go from here.

Here is what I am working with.

#include <Adafruit_NeoPixel.h>
#define PIXEL_PIN 6

#define XBAND_PIN   8    // Digital IO pin connected to the button.  This will be
// driven with a pull-up resistor so the switch should
// pull the pin to ground momentarily.  On a high -> low
// transition the button press logic will execute.

#define NUM_LEDS 5
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIXEL_PIN, NEO_GRBW + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;
int XBandState = LOW;
int val = 0;

void setup() {
  pinMode(XBAND_PIN, INPUT);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Get current button state.
  bool newState = digitalRead(XBAND_PIN);

  // Check if state changed from high to low (button press).
  if (newState == HIGH && oldState == LOW) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(XBAND_PIN);
    if (newState == HIGH) {
      showType++;
      if (showType > 1)
        showType = 0;
      startShow(showType);
    }
  }

  // Set the last button state to the old state.
  oldState = newState;
}

void startShow(int i) {
  switch (i) {
    case 0:  Pulse(true, random(5, 20), random(5, 10),
                     255, 0, 0, 0,
                     true,
                     5,
                     25, 50,
                     1);
      break;
  }
}

void Pulse( boolean FadeIn, int StepsIn, int FadeDelayIn,
            byte red, byte green, byte blue, byte white,
            boolean FadeOutA,
            int NUM_LED,
            int StepsOut, int FadeDelayOut,
            int EndPause)

{
  int i;
  for (i = 0; i < PIXEL_PIN; i++)
    showStrip();
  if (FadeIn ==  true)
  {
    float r, g, b, w;
    for (int p = StepsIn; p >= 0; p--)
    {
      r = (red / p) / p;
      g = (green / p) / p;
      b = (blue / p) / p;
      w = (white / p) / p;

      for (i = 0; i < NUM_LED; i++)
      {
        strip.setPixelColor(i, strip.Color(r, g, b, w));
      }
      showStrip();
      delay(FadeDelayIn);
    }
  }
  if (FadeOutA == true)
  {
    float r, g, b, w;
    for (int j = StepsOut; j >= 0; j--)
    {
      r = j * (red / StepsOut);
      g = j * (green / StepsOut);
      b = j * (blue / StepsOut);
      w = j * (white / StepsOut);

      for (i = 0; i < NUM_LED; i++)
      {
        strip.setPixelColor(i, strip.Color(r, g, b, w));
      }

      showStrip();
      delay(FadeDelayOut);
    }
  }
  delay(EndPause);
}

void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
  // NeoPixel
  strip.show();
#endif

}

void setPixel(int i, byte red, byte green, byte blue, byte white) {
  strip.setPixelColor(i, strip.Color(red, green, blue, white));

}

void setAll(byte red, byte green, byte blue, byte white) {
  for (int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue, white);
  }
  showStrip();
}

    for (int j = StepsOut; j >= 0; j--)This for loop would seem to be responsible for fading the LEDs. What happens if you change the loop end condition from 0 to a larger number ?

UKHeliBob:     for (int j = StepsOut; j >= 0; j--)This for loop would seem to be responsible for fading the LEDs. What happens if you change the loop end condition from 0 to a larger number ?

Thanks for your response. I have played with that a little and it does makes the pulse end at low dim but when the pulse is triggered again it starts from 0 brightness.

[/code]for (int j = StepsOut; j >= 2; j--)[/code]

Smaller numbers (1-15) seem to create varying amounts of light at the end of the pulse. 2 displaying something similar to a 50 brightness out of 255. Larger numbers like 50 make the pulse erratic.

but when the pulse is triggered again it starts from 0 brightness.

Why? You need two for loops. One runs from minBright to maxBright. The other runs from maxBright to minBright.

You are NOT required to start or end at 0 or 255. #define two names, minBright and maxBright, with appropriate values. Use those names as the lower and upper bounds of the for loops.