LEDs Are Everywhere - Developing the Fading Rainbow Light Show!

RPDMS Home Page Link LEDs, those little points of bright light, once relegated to being power and status indicators in our electronic devices have migrated to being incorporated in just about every device that needs to emit light for some reason. They seem to be everywhere, our homes, our offices, our cars, street lights, other signage, and once the costs decrease enough through volume usage, will most likely eliminate lighting as we have known it since Thomas Edison invented the light bulb.

Following are the technical development details of likely the most unique RGB LED color light show available to date, at least running in a baseline microcontroller. If these things bore you then go directly to the dedicated, less technical Fading Rainbow Light Show page where you can get more information and even be lucky enough to have your own personal light show.

We'll not discuss the pro's and con's of these gizmo's but will describe the use of a particular type most interesting to the field of color science. The tricolor RGB variety which in fact, is actually three LEDs in a single envelope most often sharing a common cathode or anode in some cases. Digitally drive one of these using an 8-bit microcontroller and one can turn off or on at will, in any particular pattern, the seven unique color combinations formed by switching single elements, binary pairs, or all three.

Red, Green, Blue, Red + Green (Yellow), Red + Blue (Magenta), Green + Blue (Cyan), Red + Green + Blue (White) are the general hues produced. However, the actual perceived color of these combinations depends upon the interaction of the primary wavelengths and bandwidth of the individual elements, the relative intensity of each and the voltage or current driving them. It is common to see these colors being displayed or flashed by a multitude of objects once one becomes aware of these little "bulbs".

Flashing LEDs

What a waste of resources!

The capabilities of these RGB LEDs is far beyond what is shown here employing the simplest binary on/off method of display. People prefer a more ordered world of color, in particular, the fading rainbow spectrum we're accustomed to seeing. Consider that controlling the relative brightness of each element to 64 levels would produce (64 x 64 x 64) 262,144 combinations or better yet, utilizing the full 8-bit capability of the simplest microcontroller (256 x 256 x 256), produce 16,777,216 colors combinations as we'll see later. Using this latter method, a single RGB LED is capable of displaying a device dependent color space akin to sRGB standard shown. I try to refrain from using colors and combinations as being synonymous since color is a human thing and if two or more RGB combinations are below the threshold of human color difference perception, they're not different colors but merely several RGB combinations resulting in the same color! A fact often overlooked in our computer age where 24-bit, 32-bit, 64-bit, ... color terminology is often used for bragging rights. However, we'll continue to use both terms while keeping in mind this difference.

sRGB Color Solid At left is the 1976 CIELab plot of the 16+ million sRGB color gamut. More on the shape of RGB color spaces can be found here . This plot was made using the 1931 CIE chromaticity information (x,y) for each color (R, G, and B) to calculate the CIELAB coordinates for each of the 16+ million unique combinations of these three primary colors. This same information can be computed for any tricolor LED with known spectral distribution data or lacking curve information, at least the dominant wavelength chromaticity (x,y) for each color.

How do we make a color show?

To make a light show we must decide on a sequence of colors to be presented. Most often it is simply through what I term a logical presentation sequence formed by letting R go from 0 to 255, followed by incrementing G to 1 and repeating R0 - R255. Increment G again and repeat R cycle until we've shown all the possible RG combinations. Now start incrementing B one step at a time while repeating the entire RG sequence in between each step. When B gets to 255 we have gone through all 16+ million combinations.

Is there a better way?

sRGB Color Solid Top View Here's a top view of the sRGB color solid showing the '76CIELab a*b* plane. The human visual system is somewhat similar by having retinal cones connected to the optic nerve and brain via two like opponent color channels. Since history has shown people to generally judge hue differences most critically, we might want to arrange our show to progress in that direction. Doing so will naturally minimize the hue changes from color to color with chroma differences next and lightness being largest change. This follows the information confirmed by the famous MacAdam Ellipses plus we'll have the preferred spectrum, or soothing fading rainbow show.

Color Sequenced Paths Around sRGB Color Solid Top View To the right is the sRGB top view with a dozen or so hue direction traces illustrating perceptual, fading rainbow sequence mentioned above. Each step is taken to the nearest hue difference neighbor with a positive hue angle (h in the 1976LCh System). Repeating this while maintaining similar chroma will result in eventual closing of the somewhat hexagonal shape. We then move to the nearest point away from where we've been and continue the process. The number of traces is reduced in the graphic to better show the principle.

A DOS/Windows executable demonstration program has been written illustrating these two presentation methods. Depending upon the age and type operating system plus your security settings, you may be able to either run or save this program by clicking the next picture, a screen shots composite of the actual program (at 57° and 335° hue angles) illustrating how Fading Rainbow Light Show truly fades these colors. Don't worry it is safe!

Sample Program Icon

Hopefully you were able to run the above demonstration program and observe the amazing difference between the two methods for ordering color presentations. You will have noted the program doing more than simply illustrating two opposing ways for exploring RGB space. Technical details were added to further my own studies regarding the merits of DE2K as successor to DEcmc. Sort of killing two birds... What's important here is the hue priority method of color sequencing. During my years of collegiate and industrial teaching and training, students given a series of color chips with instructions to form a hue circle going outward from the center in steps of increasing chroma have little problem completing the task. Prior color experience seldom seemed to have much effect on this ability. It seems so "natural" to people that color wheel arrangements have become the norm for organizing colors, exactly as demonstrated by the perceptual, fading rainbow arrangement.

Color Sequenced Paths Around sRGB Color Solid Bottom View Color Sequenced Paths Around sRGB Color Solid Bottom View
Above left is the bottom view of the sRGB color solid with the hue direction traces shown to the right. These represent colors that are darker than the corresponding Chromax (my own term for each hue's maximum chroma) triplet combinations. For the most part they are dark, lower saturation colors contributing little to a "light show" but were included in the demo to illustrate the natural ordering principle. If you were able to run it, and depending upon your monitor settings, you might have thought nothing was happening initially before getting into the lighter colors. To avoid this, only these lighter colors from this bottom view are included in The Fading Rainbow LED sequence. Also, to better show nuances of human simultaneous contrast and adaptation, the show is divided into two sections, first proceeding in a positive hue direction, and lastly reversing to a negative going sequence. Positive progression is Red, Yellow, Green, and Blue and in between hues. Negative proceeds Red, Blue, Green, and Yellow. Think clockwise (-) and counterclockwise (+) for the above pictures

Keep in mind that color is a function of the eye-brain connection, constructed in such a manner that the brain supplies details that may or may not have been present in what the eye saw! Our color perception is often influenced by both colors previously viewed as well and colors viewed simultaneously. Order of presentation can enhance our color perception experience. In case you missed it above, see here for classic illustration of brain seeing something the eye didn't.

In summary, The Fading Rainbow Light Show might be better described as a Perfect LED Rainbow Light giving one a color experience found nowhere else on the WEB, or likely anywhere else for that matter.

OK, we have a color sequence - Fading Rainbow. What's next?

Our goal is to use a very small digital computer, or microcontroller, whose outputs are said to be tri-state, i.e. high, low, and neither or as interpreted by our LED, on or off. How then will we be able to use such an arrangement to obtain the 256 levels needed to achieve the desired perceptual color transition for our RGB LED? Enter PWM, Pulse Width Modulation, taking advantage of the speed potential for these devices to switch on/off. Even the baseline microcontroller intended for this application has a clock speed of 4 MHz (4,000,000 cycles/second), a tiny bit slower than the 4.77 MHz of the original IBM PC. Even at this snail's pace, by modern clock speed standards, we still measure time in milliseconds and microseconds.

The easiest way to understand PWM is by imagining some very short, but finite time period, say the time required for our device to switch on/off 256 times. If we kept our LED turned on for exactly one half the cycles and off for the other during this period, it would behave as if it were receiving half voltage by glowing at reduced brightness. Think of PWM as analog simulation using a digital device. The on time is called the duty cycle thus giving us our solution, 256 duty levels created by first being off the entire time (0% duty) followed by on 1, off 254, then on 2, off 253 ... on 254, off 1, to the highest and final level of being on the entire time (100% duty). By keeping the period short enough we never see the on/off pulsing or even know it is taking place just as we don't see the single video frames of a movie. There is one slight drawback however, this progression, although linear in nature, will not be seen as equal brightness steps. No further discussion of this very complex matter, except to say this non-linearity is handled by the microcontroller program's use of the 1976 CIELAB L* lightness function for improved uniformity.

Go here to see how L* is used.

Selecting the controller.

To modulate the RGB elements separately would best require three PWM capable output pins on our microcontroller, hereafter referenced as PIC® for brevity. Checking Microchip's web site (the maker of PIC chips) shows only 2 baseline PICs having 1 such pin and only one family of 4 PICs among their midrange PICs having 3 PWM output pins. Chuck hardware PWM, we'll take another approach. Even if we had a suitable PIC we are still faced with coming up with the duty numbers for each color in our show progression. Given higher level floating point capability, we could just do all the calculations like the demo program, created with MS Visual Studio. Using one of the higher level PIC programming languages as Basic or C would most certainly far exceed our baseline memory. Even so, knowing the needed triplets (RGB duties for each color in our show), we're still faced with how to make them available to the PIC program. One technique would be data tables - most certainly beyond the memory capacity of our PIC.

®-Registered trademark of Microchip Technology Incorporated

Our goal - aim high while keeping it low!

Back in November 2011, a neighbor asked my help in repairing a flashing LED candle. This work soon led to the discovery of PIC microcontrollers. In spite of 45+ years as an industrial process engineer, color scientist and computer programmer, I was amazed at the potential of these "little computers" to be adapted to just about any data gathering, communication and control function. These were just inexpensive, somewhat scaled down versions of the programmable controllers I'd used for years in industrial automation. Microchip actually distributes a complete IDE (Integrated Development Environment) package enabling one to program these using assembler. The big plus, it's free and the programmer itself is very inexpensive with lots of resources to even build your own interface if desired.

The task evolved into using my color science background and machine language experience to create a perceptual LED color show unlike anything common in the marketplace at the time. To keep costs low, the bottom end of the baseline PICs, 10F200 was chosen for the task. Among the smallest available architecture, it is an 8 bit processor with a 2 level stack, 16 bytes of data RAM, 384 bytes of program memory, one 8 bit timer and no PWM capability. Since each instruction is 12 bits wide, the 384 bytes translates into 256 words of program memory. Therefore, the light show must be achieved in 256 steps, utilizing very limited data storage, and almost no nesting of calls to subroutines. Hours of Internet searching for any information about such an undertaking came up empty. Evidently, anyone with experience would know this task is impossible, or at least it would appear that way.

The algorithm was in development for more than a year, but we got there!

Believe it or not, after 4 or 5 program generations of limited success, I'm now surrounded by PIC10F200's running a perceptual, fading rainbow color show that, due to the narrow band nature of the LED's compared to monitor RGB, is much brighter and more saturated than the demo show!

Fading Rainbow Boxes

Fading Rainbow Circuit Board

The circuit board is shown to be quite simple and compact since the functions normally performed by external circuitry are incorporated into the microcontroller (PIC10F200) program leaving only the three color balancing, current limiting resistors and a safety protector diode. Even this balancing function was programmable, eliminating the resistors while overwhelming the limited baseline processor resources. This approach was discarded early in the development. Replacing 8-pin DIP with the small outline SOT-23-6 package could result in a dime sized board or even smaller. Increasing resources as needed to eliminate the resistors and one can only guess the ultimate package size, maybe just an LED connected to the legs of a controller?

And now another year has past and below is the Generation #4 Fading Rainbow controller board sitting on a penny above a dime to show its size. The balancing functions have been incorporated into the programming, eliminating need for resistors and a new method for mounting the LED is used. About as small as can be made using DIP controller configuration.

Fading Rainbow Circuit Board

6 Color Rainbow Video There are examples everywhere showing an RGB LED easily fading through the six ordinary combinations of red, yellow, green, cyan, blue, and magenta hues. Click picture to see another one here and now. We can even visually classify some intermediate hues maybe dubbed as orange, yellow-green, etc.This familiar sequence, seen hundreds or maybe thousands or more times on web sites hyping marvelous accomplishments or some great new LED lighting product, simply involves presentation of 1529 RGB combinations! Start with green and add 255 steps of blue resulting in cyan. Reduce green in 255 steps to transition to blue followed by 255 steps of red to produce magenta. 255 step reduction of blue leaves us seeing red. Follow this with 255 increments of green to produce the yellow and finally reduce the red in 255 steps and, voila, we're back at the green starting point 1529 combinations later. Well, actually 1530 steps but we started and ended with green, not counted the second time.

The above sequence represents traversing only the narrow outer edge of our top view leaving a big black hole in our RGB color solid by eliminating thousands or maybe even millions of pastel combinations! No one knows for sure how many different colors humans can distinguish. No one has counted them yet as far as I know. Ten million was a number proposed years ago but more recent cone studies indicate the number to be closer to a million unless you are one of the females with four cones (tetrachromats) that maybe can detect 100 million!
Rainbow Path

Delta E and the JND Concept - Just Noticeable Difference.

Delta E, the universally accepted term for a single number representing the magnitude of color difference between two samples. What is not so commonly accepted is how to calculate it. A workable formula must allow for the non-uniformity of color spaces as well as the human visual system's varying discrimination among colors (like reds, greens, etc.) and the even more complex breakdown of whether the differences are hue, chromaticity or lightness or mishmash of all three. Since the birth of colorimetry in 1931 or so, those in the industry have sought the holy grail of colorists, something that works! 1984 CMC method (British refinement of JPC79) has been time tested and although it has some weaknesses, nothing better exists yet.

Yet to be defined is how DE relates to what we see and how close do a pair of colors have to be for us to accept them as a match. The automobile industry has always been a major driver of this crusade and DEcmc of 0.4 seems to be a common acceptability number. However, separating acceptability and perceptibility raises another question, what is the smallest difference that humans can detect, better defined as JND. And, how many JND's are deemed acceptable? Not questions to be answered here or maybe anywhere else for that matter. That being said, 0.2 - 0.3 DE is suspiciously in the neighborhood of being JND for a large portion of color space as defined by 1976 CIELAB/LCh and calculated using the CMC method.

How does this all relate to Fading Rainbow Color Show?

If you were able to run the demo program you may have already noticed that DEcmc values between successive colors are shown throughout the show. For the most part, except for the very dark colors, many differences are often below 0.2 - 0.3 that I prefer to call UND, Un-Noticeable Difference. Slowing the color progression while studying the numbers seems to verify the presence of millions of RGB combinations indistinguishable to people (trichromats) with normal color perception. Absolutely essential for acceptance that we humans maybe only perceive around a million different colors! You may have also noticed the counter keeping track of the ~100,000 combinations being presented. A small dent in the 16,777,216 million available. We skipped 99.4% of the combinations and you didn't notice many gaps as a result.

Still having trouble with the 1,000,000 color idea?

Consider the following graphic created with Photoshop using only RGB combinations ranging from 0-0-0 to 50-50-50 inclusive. Amazingly so, this represents human perception of gamut limits for nearly 133,000 darkest RGB combinations. Notice use of combinations versus colors! Need I say more? Any tetrachromats out there or normal trichromats for that matter, please, click here to see what is really in this image and feel free to let me know what you see.

There's a lot of color science in The Fading Rainbow Light Show.

The Fading Rainbow is unlike even the six color, 1529 combinations discussed before. Who knows for sure how many of those are unnecessary because 3 or more successive combinations may still be well below UND and seen as the same color, thus only wasting controller resources. I guess I could try counting the combinations to be sure, not worth the effort though. The black hole in our color solid is filled in by the Fading Rainbow Color Show presenting those colors in UND sequence. Without some visual reference one does not perceive the individual changes and on the longer shows, may not be aware of the changes that just simply seem to happen unknowingly. Warning: Watching these shows can be addictive!

The Fading Rainbow is really unique among LED color shows and has to be seen to be appreciated. After many failed attempts to capture its essence on video and still cameras, I've given up for the present. It was designed to be a human visual phenomenon and true to its roots, fails to impress inanimate capture processes. See another example of eye versus camera differences (third time's a charm) here.

Circuit Description

Thanks for your attention and please, visit our dedicated Fading Rainbow Color Show Web site .

E-mail inquiries, questions or suggestions. Please don't change the subject or your message may get junked. Thank you and goodbye for now.