'In the main programo loop, you first take a look at the start and end RGB values and work out what value is needed as an increment to progress from one value to the other in 256 steps (as PWM value can only be between 0 and 255). You do this with the following:

for(int x=0; x<3; x++) { INC

=(RGB1

-RGB2

)/256; }

This 'for' loop sets the INCrements values for the R, G and B channels by working out the difference between the two brightness values and dividing that by 256.You have another 'for' loop

RGB1[0] -= INC[0]; RGB1[1] -= INC[1]; RGB1[2] -= INC[2]; }that sets the red, green, and blue values to the values in the RGB1 array; writes those values to Digital Pins 9, 10 and 11; deducts the increment values; and repeats this process 256 times to slowly fade from one random color to the next step. The delay of 100 ms in between each step ensures a slow and steady progression.

After you have taken 256 slow steps from one random color to the next, the RGB1 array will have the same values(nearly) as the RGB2 array. You now need to decide upon another set of three random values ready for the next time. You do this with another 'for' loop:

for (int x=0; x<3; x++) { RGB2

= random(556)-300; RGB2

= constrain(RGB2

, 0, 255); delay(1000); }

The random number is chosen by picking a random number between 0 and 556 (256+300) and then deducting 300. In this manner, you are trying to force primary colors from time to time to ensure that you won't always just get pastel shades. You have 300 chances out of 556 in getting a negative number and therefore forcing a bias towards one or more of the other two color channels.The next command makes sure that the numbers sent to the PWM pins are not negative by using the 'constrain()' function.As you use random(556)-300 for you RGB values, some of those values will be lower than zero; the constrain function makes sure that the values sent to the PWM is not lower than zero.'