A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
Hi, does anyone have any source codes for flashing an RGB(tricolour) LED using a PIC 12F675 or similar PIC?? I'm doing a project on it, and need some help with the coding. Have to use assembler, but even C would do. trying to program it by using different hex values and varying the duty cycles to produce all colours of the spectrum using red green and blue. HELP!! Asha |
|
This sounds like a fun project. An LED colour changer. You're basically looking at a simple PWM controller to control the LED intensity. As the smaller PICs have only one PWM, you'll have to do it in software. Start easy with just one LED and vary the intersity. As this sounds like homework, I'm not going to give you any code, just the idea on how to do it. Example for 50% intensity. Start: turn on the LED load counter 1 with 128 load counter 2 with 256 loop decrement counter 1 (when counter 1 reaches zero, turn off LED) decrement counter 2 (when counter 2 reaches zero, goto start) goto loop The intensity can be changed by setting a new value for counter 1, Smaller value, lower intensity. This example is really crude, but it will work. You'll find the limitations when you use it :) Good luck, Eugene asha_2108 wrote: >Hi, >does anyone have any source codes for flashing an RGB(tricolour) LED >using a PIC 12F675 or similar PIC?? I'm doing a project on it, and >need some help with the coding. >Have to use assembler, but even C would do. trying to program it by >using different hex values and varying the duty cycles to produce all >colours of the spectrum using red green and blue. HELP!! >Asha |
|
----- Original Message ----- From: "Eugene Gopalan" <> To: <> Sent: Tuesday, March 22, 2005 8:42 AM Subject: Re: [piclist] HELP- PIC LED flasher > > This sounds like a fun project. An LED colour changer. > You're basically looking at a simple PWM controller to control the LED > intensity. As the smaller PICs have only one PWM, you'll have to do it > in software. > Start easy with just one LED and vary the intersity. As this sounds like > homework, I'm not going to give you any code, just the idea on how to do > it. > > Example for 50% intensity. > Start: turn on the LED > load counter 1 with 128 > load counter 2 with 256 > loop decrement counter 1 (when counter 1 reaches zero, turn off LED) > decrement counter 2 (when counter 2 reaches zero, goto > start) > goto loop > > The intensity can be changed by setting a new value for counter 1, > Smaller value, lower intensity. > > This example is really crude, but it will work. You'll find the > limitations when you use it :) That's a neat way to do simple PWM, I haven't seen it before. Leon |
|
On 'the
other' piclist - www.piclist.com - there was a discussion on this a few weeks back.
I didn't pay took much attention to the result, but it will be in the
archives.
Various
methods were discussed, including compensation for the fact the different colours appears
brighter to the human eye at the same power level, ie green > red > blue. Also
went thru fading smoothly between colours.
Our
eyes are most sensitive to green, and anyone who has looked carefully at a 15,000mCd green
LED while wondering if it works, and then finding out that it does indeed work, will
agree. Who needs a laser to blind yourself with?
Tony
|
|
Hai,
My advice is to connect 3
pinsRGB to separate pins of microntroller. create three variables as counters
for each colour. first keep two counters as constant 50% duty cycle
throgh PWM (simple run a timer and just set and clear the corresponding pin connected
to LED) counters for each then use an inbuild timer to vary the PWM duty cycle
for each colour keeping other two constant. this method will defenately work
fine use a break for each inc in count to diagonise and note the
value.
refer the led datasheet.
Regards,
Murugan V BlueQuanta Technologies, Chennai-17. Ph: +91-044-52186383 www.bluequanta.com DISCLAIMER: This message and any attachment(s) contained here are information that is confidential, proprietary to BlueQuanta Technologies and its customers. Contents may be privileged or otherwise protected by law. The information is solely intended for the individual or the entity it is addressed to. If you are not the intended recipient of this message, you are not authorized to read, forward, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly,
|