PIC based R.G.B LEDs


One thing I've been learning how to do lately is software based PWM on PIC devices, so I though I'd have a go at implementing three of them on a single PIC and use them for making a colour changing light source.

Well, I got the software to work (It's not very good, but it does the job) which can either cycle through colours or stay with one colour all the time, now all I needed was to interface it to some RGB LEDs.


First circuit

First circuit was a prototype, and had some mistakes that should not be repeated. Hence I will not be giving out the circuit diagram, but there are some pics of it in action.

For the LEDs I bought 15 of these 4-pin LED's. They are set up in common-anode mode, meaning that 3 pins take a positive input and one pin takes the negative/ground:

Here is the circuit after I wired three of these in parallel (series wiring is not possible with these LED's):

 The three transistors are BC337 NPN types, the PIC is a PIC12F675 and the 5V regulator (for the PIC) is a 78L05.

Once I got it to work, I decided to wire the remaining 12 LED's into two sets of 6, as so:

Once that was done , It was on to testing. First test involved putting about 3V over each of the colour pins and the GND, primarily to make sure all the LED's were wired in the right orientation, and to make sure that all the colours fired off in unison. Below you can see the results of the green channel:

This was a success, so I plugged it into the breadboard directly, and programmed the PIC to alter between the channels, below you can see the green and blue channels on at the same time:

I was happy with the colour mixing (although you can see a green/blue split if you look directly at them). After the testing I cut out the two pieces and continued to use them with the prototype.

Two types of RGB LEDs

RGB LEDs are really three LEDs connected together in one package with 4 pins. As such there are different ways of them being wired. Common cathode and common anode.

In common anode, the positive pins of all three led's are wired together, and the negative pins are seperate. In common cathode, the opposite is the case. This is important as we need different circuits to drive them.

 I finish this article as soon as I get the geda suite working on my machine (no packages for archlinux apparently).