I am trying to generate a random color RGB value -> light up RGB led -> wait for 5 minutes -> generate next random color -> fade from old color to new color.
- For showing the color on LED I am using 3 channel PWM output on ATMEGA8.
- For generating the random color I am using TIMER0 as seed value and then generating a random value according to formula
return (unsigned char)(rand()/(RAND_MAX/255 + 1));
for the 3 channels.
Now since I want to show the intermediate colors as well (using PWM), here is what I am thinking of doing:
- total transition steps = 500
- time to show each intermediate color = 5ms
- redStep = (finalred - initalred)/500 (same for green and blue)
- for loop (1 to 500) : show color intialred + (counter*redStep)
My question being, is this the best way to transition between colors, to produce the most aesthetically pleasing colors (without any flickers etc)? Also any thought on the number of transition steps and hold time?