Arduino: Change the color & color intensity of a LED periodically
I agree that the switch statement smells. One way to avoid it is to abstract LED values into the array, and let change_color_intensity operate on it:

void change_color_intensity(int which, int start, int stop, int delta)
{
    int values[] = { 0, 0, 0 };
    for (values[which] = start; values[which] != stop; values[which] += delta) {
        set_leds(values[0], values[1], values[2]);
        delay(DELAY_WITHIN_LOOP);
    }
}


Note that I change a while loop into a IMHO more readable for. I also changed some names for the same reason.



Another approach is to abstract LED names, and get rid of setLed altogether:

void change_color_intensity(int which, int start, int stop, int delta)
{
    for (in value = start; value != stop; value += delta) {
        analogWrite(which, value);
        delay(DELAY_WITHIN_LOOP);
    }
}


with the caller defining a pin array:

    int LED = { RED_LED_PIN, GREEN_RED_PIN, BLUE_RED_PIN };
    for (pin = 0; pin &lt; 3; pin++) {
        change_color_intensity(LED[pin], 0, 256, 1);
        ....
    }




I am not sure I understand what you mean by multiple function invocations. If you are concerned with invoking change_color_intensity twice in a loop, I see no problem with it.