michael brown wrote > Sergio, > > Thanks for the reply. I didn't have time to implement your prior > suggestion until yesterday. It looks pretty good and I appreciate your > help. > > The problem I'm having with large steps is that the PWM is linear but > the brightness is not. And even with a bigger resistor on the blue, > it's still having an overbearing effect on the color. I'm now trying to > come up with a good technique for turning off one LED at a time for > several seconds to give the other two a chance on their own. I suspect > that to get the effect that I really want, I will have to use tables. > > Right now, the PWM is being done by TMR2 ints and the colors are > adjusted in the main level loop. I'm thinking that I will use another > timer to control the ramping up and down of the color intensity to move > that process into the background. The main level will then be able to > start a red, green or blue color cycle and use main level delay loops to > phase them apart from each other and to wait out the cycles. With a > delta of one and changing the intensity (PWM value) every 20mS, it will > take a little over 5 seconds for a color to ramp up or down. > > I should be able to start the red ramping up, wait 5 seconds and then > start the green. Hopefully this will result in the red ramping up and > holding at full on while the green comes up 5 seconds behind it. I hope > to see the red transition to orange and then to yellow as this occurs. > I then start the red on a descending ramp to transition from yellow to > green. 5 seconds later (as the red is going out) I start the blue > coming up which ends in a nice cyan color hopefully. 5 seconds later > start the green's descent and when that's complete I will start the red > coming up to transition the blue into nice purples. I'm hoping to see a > virtual rainbow in the "natural" sequence. Hi Michael, You should give the new algorithm a try, you will find that green stays off (or very low) for the first 23 steps, then red and green slowly mix while blue stays off (or very low) for the first 437 steps of each group of sub-combinations. This may give you the ramp(?) effect you are looking for. Also if you feel that blue is too bright, you can reduce the brightness by limiting the range e.g 0-127 will limit the brightness to half and can be achived by simply masking i.e. blue = blue + 1 blue = blue & 0x7ff // limit to half brightness or blue = blue + 1 if blue > 192 then blue = blue + 64 // limit to three quater brightness endif Regards Sergio Masci http://www.xcprod.com/titan/XCSB - optimising PIC compiler FREE for personal non-commercial use -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist