RGB LEDs can produce any color inside their spectrum, the same as your computer monitor. It is basically limited by how pure the red, green, blue are, and the maximum intensity of each. I'm thinking "all possible colors" means any color. Thing is, you can do several things: -No PWM, plain Red,Green,Blue only, cycling all three. -No PWM, combinations: Red,Green,Blue,Cyan(Blue+Green)'light blue',Magenta(Blue+Red)'purple',Yellow(Red+Green). Plus white and/or black if you like. Total 8 colors. This is just 2^3. -PWM, middle intensities (half red, etc). Many more colors (3^3=27). -PWM, more intensities. You can do 4 intensities each (0%,33%,66%,100%) which gives you 4^3=64 colors. etc all going up to what would be hicolor in PC-speak (32768 colors, which is 5bits red, 5bit blue, 5bits red (32 colors each, 32768 colors total) Or truecolor, millions of colors (8bits each, 256 possible intensities each, total of 16777216 colors). The program for N-colors PWM (N colors for each channel, not total) for RGB would be something like each timer tick/overflow/interrupt/whatever increment PWMCnt if PWMCnt>=(Ncolors-1) PWMCnt=0 Rvalue2=Rvalue Gvalue2=Gvalue Bvalue2=Bvalue endif if Rvalue2>PWNCnt Rpin=1 else Rpin=0 endif if Gvalue2>PWNCnt Gpin=1 else Gpin=0 endif if Bvalue2>PWNCnt Bpin=1 else Bpin=0 endif return And then, in the main loop, run something that changes Bvalue, Rvalue, etc. Note that I cache the value to prevent changes during a PWM cycle. Try with several values for the timing. For example, for a 256 values per channel PWM, try something like each 1ms and go lower until the flickering disappears. Usually 64 values per channel will suffice, and will flicker much less and won't need the loop run so often. To cycle through all colors (hues, no black or white in this example, no brightness or saturation, just hues) you can run something in the main loop that does, for example: (start with red=100%,blue=0%,green=0%) repeat forever: (total color is now red) ramp green from 0% to 100% (total color is now yellow) ramp red from 100% to 0% (total color is now green) ramp blue from 0% to 100% (total color is now cyan) ramp green from 100% to 0% (total color is now blue) ramp red from 0% to 100% (total color is now magenta) ramp blue from 100% to 0% (total color is red again) end repeat note that after a ramp the color remains at the end value, i.e. "ramp red from 100% to 0%" does NOT mean touch the blue or green channels, just leave them as they were after the last ramp. If you want to avoid timers, and you do not intend to do anything else other than cycle the LED, you can do something like the following, in which case you can also remove the caching of the values in the PWM subroutine: subroutine ramp(*channel,from,to): *channel=from repeat until *channel>=to: increment *channel repeat N times: (N depends on the speed on the effect, how much each separate color stays before changing into the next tick, in units of PWM cycles) call PWM subroutine delay (this is the PWM delay) end repeat end repeat end subroutine main program: repeat forever: ramp(&Gvalue,0,max_color) ramp(&Rvalue,max_color,0) ramp(&Bvalue,0,max_color) ramp(&Gvalue,max_color,0) ramp(&Rvalue,0,max_color) ramp(&Bvalue,max_color,0) end repeat (where max_color equals Ncolors-1) Note that I use */& the C way, since passing the value to the subroutine won't do any good, you want to be able to CHANGE the value. Or make 3 ramp subroutines, one for each color, or pass a value 0 for red, 1 for green, 2 for blue, or whatever. Of course the purity of the colors will be affected by the different intensities. I recommend hooking up the outputs from the PIC to some transistors and adding a pot to the base to be able to adjust individual brightness. HTH, -- Hector Martin (hector@marcansoft.com) Public Key: http://www.marcansoft.com/hector.asc -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist