Of course the call to analogWrite doesn't change the Variables... Sorry, i think i didn't explain myself very well, i wrote a function that write the RGB Values to 1 of 5 LEDs the function looks like this:
void ledWrite(int led_number, int r_brightness, int g_brightness, int b_brightness) {
int r_pin = led_pins[(3*led_number)-3];
int g_pin = led_pins[(3*led_number)-2];
int b_pin = led_pins[(3*led_number)-1];
analogWrite(r_pin, map(r_brightness, 0, 255, 255, 0));
analogWrite(g_pin, map(g_brightness, 0, 255, 255, 0));
analogWrite(b_pin, map(b_brightness, 0, 255, 255, 0));
}
And now i want to make a new function witch handles the whole fading process, but since i have to keep the code running also while fading, i just call the function every loop, and i thought the function could just have a target color whitch you specifie and then every time it gets called, just read the current pwm value and increment it one step closer to the target color, and i just meant that all the variables used in that function would be overwritten each loop (every time the function is called), but i just remembered, that that doesn't matter because in this function only the target color, led number and stuff gets passed to the function, but not the brightnesses, the idea was something like analogWrite(pin, pwmRead(pin) + 1); where i wouldn't have to use variables, of course the function would first have to decide wicth color get changed and if that fade darker or brighter...
I think you are trying to see a problem that does not exist.
Actually, i'm not seeing a problem at all, or at least, not a real problem, i mean i can stil run the code, no matter if the values get read from somewhere, or saved in variables, i was just curious, and i think we can all agree that in some cases this would be practicle (assuming you don't have to write a bunch of code just to be able to read the value in the first place, of course)...
Delphiño