Color Detection Using An RGB LED


[Kyri] has made a simple circuit to do color detection using an RGB LED. Simply set the LED to the color you want to detect then wave the object over it. Another LED will light up if the object is the same color as the LED. The detection is done by a photo resistor. The theory is that an object will reflect more of the light that matches its surface color. She shows that this kind of detection could be useful for sorting in robotics.

30 thoughts on “Color Detection Using An RGB LED

  1. There’s no point ‘sweeping the spectrum’. The best you could do is do red, green and blue one after another, thus giving you the RGB colour of the object. This should let you distinguish any colour, including white.

    Nice idea, not sure how well it would work in practice.

  2. i like the idea of detecting the objects actual color by lighting it up in red, green and blue and analyzing the amount of reflected light. i just wonder how that technique works with more or less reflecting surfaces.

  3. LEDs are also photo-voltaic. They generate a voltage when exposed to light. They’re not very efficient that way, but it would be a cool challenge to see if you could do away with the photo-resistor by exploiting that.

  4. Hate to be damper, but how about 3 time 20 cents photodiodes with r,g,b filters on them, same result, without any changing of light, just a white light will do to get the result, and you can average the combined output, and display it using that now not-in-use RGB LED!
    Add 2 more diodes with polarizin filter to get some reflection data and IR filter for infra-red to make it more complex.

    Or as an alternative similar project a UV sensor maybe but in that case an illuminating UV LED to get UV reflectivity, might be interesting for some use.
    Just spouting ideas

  5. wwhat: i guess you could do that, but how would you know what color you are trying to detect? you’d have to have some LCD display with the RGB values or something like that. And an ultrabright white LED was the same cost as the RGB led

    But the UV sensor is an interesting idea…

  6. Sweeping the spectrum and measuring the light for each component would give you a more precise spectrum than a simple triplet of RGB values. It would, however, require a programmable broadband light source (or a BB radiator and a programmable filter), and I’m not entirely sure such a thing exists, at least at an affordable price.

  7. the point is using three filters method you can constantly output the colour on the rgb led of the receved light. if the intensity is above a certain threshold, or it changes suddenly etc (use your imagination) then there is an object there.

  8. edz-
    That’s exactly how an old Perkin-Elmer UV-Visible Spectrophotometer works. There’s a nice broadband (mercury-arc or incandescent, don’t recall) light source, a prism (you could use a diffraction grating, I believe), and a pair of vacuum-tube photodetectors in a Wheatstone Bridge configuration to tare out the reference beam. They’re set up as absorption detectors for chemistry, but could probably be convinced to work as very good colorimeters if you were so inclined.
    ebay has a few of ’em, if you’re interested in experimenting.

  9. There was already a hack very similar to this that does what some commenters suggested. I have seen a hack on here also that cycled through rgb several times a second and with that it measured how much of each color was reflected.

    (I’ve been reading on this site since it was created.. geez its been a while…)

  10. styko: As far as more/less reflective objects, I think you’ll still be pretty successful if rather than using the real measured values of the amount of reflected light for each color, you simply compare the ratios of the 3 different amounts of reflected light to determine the correct color.

  11. This is the very same principle as scanners, they have a cold cathode led, and then a long sensor that detects the amount of reflected light in every color. somethin’ like that…

  12. Call me stupid, but the colour of an object is merely the absorption of all light EXCEPT that colour (wavelength of visible light). So does this circuit detect the absence of reflection within a predefined tolerance of the spectrum? Commenters discussing the “peak” would then be correct but backwards; it’s the valley you’re looking for, not the peak.

    Another question… Yellow light is around 570nm wavelength and orange is 590nm. So how would it distinguish an object at 580nm? The source would have to be at a matched wavelength or have a tolerance of x nm in order for it to qualify as “matching”.

  13. @diddle: an object appears also in some colour if only the complementary colour is absorbed.

    for example, if you set the rgb leds to FF,FF,00 => full red and full green brightness but no blue, you will get yellow, because yellow is the complementary colour of the absent blue. you will get the maximum reflection for a yellow object, because red and green are fully reflected. if the object is blue, it would reflect the green light, but not the yellow light, so you’ve got only the light of one led reflected and not the light of the two leds that you’ve set to full brightness

  14. you’d want to use a photodiode for color detection.
    a cmos sensor or ccd would be what you would use for image scanning. The planon docupen scanner (rc800 plastic piece of crap from hell, don’t buy) used the RGB cycling method (with a tri-color LED) to produce color scans. Therefore the scanner did not actually see in color, it just sampled the light intensities in red, green and blue independently to come up with an interpretation of a color image.

  15. 1.) You can’t “sweep the spectrum” with the finite number of peaks (in this case three) you get with LEDs.

    2.) You guys all don’t know what colors are, except for diddle who used his/her brain. And there are no “complementary colors” except in our brains. Let me try:

    (skip this paragraph if you are scared)
    Multiply the light source’s color spectrum with the material’s reflectance spectrum and you get the “color” that reaches the eye/camera. Now multiply that with the response spectra of the cones in the eye or the camera’s CCD chip and integrate. (By multiplying these functions i mean something like f*g(x)=f(x)*g(x).) Now you have a color value.

    With your method you will get values that look about right in most cases, but consider some material that has a reflectance spectrum with one peak (say, yellow) between two peaks of your leds (say, red and green). This will show up as black when illuminated with the seemingly yellow light of the combined leds, although it appears yellow under full-spectrum light like sunlight.

    (ok, it will not be black since the peaks are of some width and maybe even overlap. But it will be darker than it should be, which is my point.)

    Read wikipedia, it helped me.

  16. Can someone tell me what are the cool technology on color detection or other similar ideas?

    me and my partner, undergrad students, would like to make a thesis topic out of it. Course is Electronics and Communications Engineering.

    we would very much appreciate your help, thank you very much.

  17. You might also be able to detect color in this manner with the LED itself. Using a microcontroller, you can reverse bias the LED to charge up the junction capacitance, then time the discharge to determine the light level. I believe hackaday posted something on this a while back. I would be interested to know if different wavelengths of light charge the junctions of the R/G/B LEDS at different rates, as this could also be used for color detection.

  18. Hi friends, I have a doubt…. I m going to built up a portable colorimeter which actually does the same as spectrophotometer. Here, im planning to use RGB led’s as a light source. will I be able to get the entire absorption spectrum?? I know we can mix up RGB colors and get new colors but it won’t be a true colour and its wavelength will be different ryt?? So, what can be the alternative for that? Can someone help pls…its very important for me to know it..

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.