So the idea here is for an RGB led to randomly get the values for each built in color: random for red, random for blue, random for green, for the analog PWM. So far no problem. Then when a button is pushed, I want the system to get new RGB values, and over the course of 5 seconds fade from the current values to the new values. I got this by getting the max value (which was higher, current or new values), subtracting the other from that, and then dividing 5000 from that value. i.e., current Red is 120, new value is 42. 120-42 = 78. 5000(ms) / 78 = 64.1. Since they are all ints, it will be 64.
So now this way every 64ms, the current value will change by 1 until it gets to the new value.
And that's just for reds. Blues and Greens will also be going through this with their own random values. The point though is for them to all change smoothly from current to new in ~5000ms at the same time.
And that's where I fall apart. I assume that I should create a function to start counting the millis, starting at 0 and ending at 5000. Every milli that passes it does a check to see if it lands on the interval value (64 in this case), and I assume every multiple thereafter until it finishes at 5000 (or just up to it, as 64 will never reach 5000 exactly). On the interval it adds or subtracts 1 from the current value to the new value and analogWrite(workingLed, currentValue);
Maybe I'm just burned and can't think of it, maybe I'll get it tomorrow, but right now I can't even think of how to start this function.
On another note, what would be a good Intermediate book for Arduino programming, or even a slightly more advanced Beginners book? All I have is this small Getting Started w/ Sketches book, and I'm looking to progress. Alas my local B&N doesn't have much.