Fading RGB LEDs

Hey, I am trying to fade an RGB LED between to colours.

I am using this code I've adapted from someone in the forums:

void FadeLED(int steps, int fadedelay, byte* fromColor, byte* tooColor)
{
byte* endColor;
  for (int fadeindex = 0; fadeindex < steps+1; fadeindex++) 
  {
    
    endColor[0] = ((fromColor[0] * (steps - fadeindex) + (tooColor[0] * fadeindex))/steps);
    endColor[1] = ((fromColor[1] * (steps - fadeindex) + (tooColor[1] * fadeindex))/steps);
    endColor[2] = ((fromColor[2] * (steps - fadeindex) + (tooColor[2] * fadeindex))/steps);

    setColor(endColor);
    delay(fadedelay);


    Serial.println(" ");
    Serial.print("fromColor: ");
    Serial.print(int(fromColor[0]));
    Serial.print("-");
    Serial.print(int(fromColor[1]));
    Serial.print("-");
    Serial.println(int(fromColor[2]));  
    Serial.print("endColor: ");
    Serial.print(int(endColor[0]));
    Serial.print("-");
    Serial.print(int(endColor[1]));
    Serial.print("-");
    Serial.println(int(endColor[2]));   
    Serial.print("tooColor: ");
    Serial.print(int(tooColor[0]));
    Serial.print("-");
    Serial.print(int(tooColor[1]));
    Serial.print("-");
    Serial.println(int(tooColor[2]));
    Serial.println(" ");
    Serial.println(fadeindex);

  }

}

But it's not producing the results I was expecting.

On the serial monitor I see:

fromColor: 96-1-0
endColor: 198-0-0
tooColor: 14-96-0

0

fromColor: 96-1-0
endColor: 198-0-0
tooColor: 14-96-0

1

fromColor: 96-1-0
endColor: 198-0-0
tooColor: 14-96-0

2

fromColor: 96-1-0
endColor: 198-0-0
tooColor: 14-96-0

3
and so on...

I was expecting for the endColour variable to be changing between fromColor and tooColor, but it just stays the same.

Am I missing something obvious?

I have tried punching the numbers into a calculator and it produces the correct results, so im guessing its a programming mistake.

Anyone shed any light on this?

Cheers,
Phil

I fixed it, the line:

byte* endColor;

should have been:

byte endColor[3];

I figured it would be something silly like that.

Phil.

Phil,

I was wondering if you had finished this project, I'm trying to write a program that receives a value from 0-100 every 20 seconds and I wanted to fade an RGB led to a correspondin color - aka. 0 = off, 1 = 255,0,0, 50 = 0,255,0, 100 = 0,0,255.

And I want to fade it through the colours to get to that colour, just like your code.

I was wondering if you had any ideas or code that could help me get started and tackle this effectively.
Thanks