I do something like below for both my 10x7 red led display and RGB leds. It's not in the background, but it doesn't take much CPU time so it may work for you. BTW please consider this is pseudo C, just program flow and idea. I just typed from memory ;o) #define MAX_BRIGHTNESS 255 // or less, more resolution == more cpu time //16 also works, then you can pack 4 bit values into an array unsigned char r,g,b; void display () { unsigned char count; //first turn on the elements if they have any brightness if (r) REDPIN = 1; if (g) GREENPIN = 1; if (b) BLUEPIN = 1; //check each brightness level, and turn off elements with less brightness first for (count = 0; count <= MAX_BRIGHTNESS; count++) { if (count >= r) REDPIN = 0; if (count >= g) GREENPIN = 0; if (count >= b) BLUEPIN = 0; //you can add a delay here } REDPIN = GREENPIN = BLUEPIN = 0; //in case r,g,b is greater than MAX_BRIGHTNESS } You could probably roll this out into your main loop and just check vs a timer instead of count. Hope that helps, Ben On Sunday, September 14, 2003, at 03:21 PM, David Euans wrote: > I am trying to use an 18F448 to light a RGB LED such that the > intensities of each LED can be varied independently. This needs to > occur in the background. The ultimate use is to have the LED change > color in response to changes in a digital rotary encoder. Using PIC > Basic Pro, I was trying to use the HPWM command to send differing duty > cycle PWM outputs to channels 1, 2 and 3 of the PIC. This has not > worked for me and may be due to not properly initializing the PWM > ECCP1CON or other registers. However, looking at the data sheet, I get > the impression that only two pins as most can be modulated at one time. > (Perhaps I'm reading it wrong). At any rate, has anyone been > successful > in having this chip provide more than two PWM outputs running in the > background. > > Thanks in advance. > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads