Color Detection Using RGB LED

Have you ever wanted an automated way to detect the color of an object? By shining light of a certain color on the object and looking at how much light is reflected back, you can tell what color the object is. For example, if you shine a red light on a red object, that light will be reflected back. If you shine a blue light on a red object, the object will absorb some of that light and less of it will be reflected back.

Step 1: Parts Needed

I used a PIC 16F887 Microcontroller, but almost any with a pulse-width-modulation capability will work.

I only need the microcontroller and RGB LED to have a wide range of color detectors, but if you only want a circuit that detects one color, you don't need a microcontroller - you only need a bright LED of the color you want to detect. The standard red LED is the "indicator LED" - it lights up when the right color is detected.

Step 2: Build the Circuit

The schematic is rather simple, and in general form, is shown below. The RGB LED is externally powered by a PWM signal.

I put electrical tape around the photoresistor so ambient light doesn't get in - only the light directly above it will be detected.

Step 3: The Code

This code was written for a Microchip PIC 16F887, but hopefully you can get the general idea. I used the built-in potentiometer on my development board to vary the color spectrum of the RGB LED (and it doesn't go through the entire spectrum because I don't have 3 PWM modules, but it's good enough)

it is very interesting i have a assignment i will provide a brief report of 1 – 2 pages (length for guidance only) documenting the best strategy for interfacing the colour sensor with the microprocessor pic 18f 2455 . my decision should be clearly justified and the next step is to carry out design work on the code and produce a set of design notes which may include:

I am making a similar device to detect a compound that illuminates one color (orange) under black light. My plan is to use a blue LED to excite the compound and an orange LED to sense it. Does anyone see any problem with this logic? Thanks.

its great...but u have to change every time the led light to sense the color ...actually i want to design a color sensor for my project which can sense RGB colors continuously without any need of changing led light every time...if there is a way plz tell me....my id : sunlitesetu@gmail.com