Fading Neopixels from a specific color to off, and vise versa

I have a table array of 10 colors as follows:

int myColors[][3] = {
  {0, 0, 0}, //no potion
  {200, 25, 30}, // 1; Wild Strawberry
  {255, 150, 0}, // 2; Dandelion
  {55, 0, 255}, // Denim Blue
  {0, 255, 0}, // 4; Chartreuse
  {222, 255, 0}, // 5; Sunglow
  {50, 50, 255}, // 6; Sky Blue
  {255, 25, 0}, // 7; Salmon
  {40, 255, 0}, // 8; Electric Lime
  {255, 0, 255}, // 9; Fuchsia
  {0, 255, 255}, // 10; Aquamarine
};

And I have 7 Adafruit Jewels, little round 'buttons', with 7 neopixels each, a total of 49 pixels

Adafruit_NeoPixel myPixels = Adafruit_NeoPixel(totalPixels, PixelsPin, NEO_GRB + NEO_KHZ800);

I need to fade 2 buttons in/out at the same time, so one is fading from 'OFF' from the color, and the other is fading 'ON' to the color.

I set the pixels like this:

    for(int x = 0; x < 7; x++) { //do this 7 times
      for (int y = Pixel1Start, y < Pixel1Start + 7; y++) { //fade the first Jewel
        //SET THE FADE VALUE HERE
        myPixels.setPixelColor(y,Rval,Gval,Bval); //set pixel values
      }
      for (int z = Pixel2Start, z < Pixel2Start + 7; y++) { //fade the first Jewel
        //INVERSE OF THE FADE VALUE HERE
        myPixels.setPixelColor(z,Rval,Gval,Bval); //set pixel values
      }
    FlaskPixels.show();
    }

So, how would I use any given color, say myColors[1], and have one Jewel fade on and one fade off. I'm familiar with fading a single LED, but not one made up of RGB values.

Hi,

To fade but also maintain the same colour, you have to fade r, g & b together in proportion.

There is an Arduino function that will help: map().

Paul

If I'm reading your post correctly, your asking to do something very similar to what I was trying to accomplish. I received much help over on Adafruit's forum. There is some code that you can add to Adafruits library for neopixels. You may want to head over to the linked post. I was able to get Neopixels to have a variable for color as well as a variable for brightness ie: setpixelcolor(i , red, 50) i being pixel number, red being (255, 0 ,0) and 50 being brightness intensity. With those variable I was able to create a breathing affect.

https://forums.adafruit.com/viewtopic.php?f=47&t=41143

int breaThe = 0;
uint32_t Red = pixels.Color(255, 0, 0);

for (breaThe; breaThe < 5; breaThe++) {
   for (brightIncrement = 0; brightIncrement < 240; brightIncrement = brightIncrement + 2) {
     for (i = 0; i < ledNum; i++) {
       pixels.setPixelColor(i, Green, brightIncrement);
       pixels.show();
     }
   }
   for (brightIncrement = 240; brightIncrement > 0; brightIncrement = brightIncrement - 2) {
     for (i = 0; i < ledNum; i++) {
       pixels.setPixelColor(i, Green, brightIncrement);
       pixels.show();
     }
   }
   for (i = 0; i < ledNum; i++) {
     pixels.setPixelColor(i, 0, 0, 0);
     pixels.show();
   }
 }

Hope this is helpful and happy programming