RGB LED


Now we'll turn our attention to lighting an RGB type of LED. In this exercise, you'll learn how to pan through 4096 different colors (mixtures of 16 different levels of red, green and blue).

Just as important from a learning perspective is that we get to use a PIC timer and interrupts for the first time. Both of these features are extraordinarily easy to tame in PIC Micro Pascal, as one look at the source code ought to convince you.

In effect, what's going on here is we'll create three simultaneous pulse trains, each with an independently controllable duty cycle, and all phase locked. By varying the duty cycles, the intensity of the red, green and blue elements within the LED creates different mixes, and hence hues. Here's a scope shot showing those three pulse trains in action:


The actually circuitry is a snap, as you'll note in the schematic here. You might want to individually adjust the resistor values to equalize the color mix.


As usual, there are many comments and hints in the source, so be sure to study it to master the details.

Click to get the source code.
Click to get the schematic PDF.

Next Project: LED Dot Graph -- Direct Drive

No comments:

Post a Comment