Build a simple RGB LED color detector with Arduino
You may think that visually sensing colors is a complicated operation, requiring a camera or other advanced sensors. This isn’t always the case, as engineer “Tech Martian” illustrates in the video below, using a photoresistor and RGB LED along with an Arduino 101 board.
His setup uses the LED to shine on a piece of paper in three colors, measuring the reflected light intensity. These reflections are first calibrated by reflecting light off of white and black paper, which can then be combined to show the colors presented in front of the emitter/sensor pair.
I got a comment and request from one of my Instructables that they would like to see an LED used as a color detector. Then, I got the idea that if I were to use an RGB LED, I can detect all the color spectrum possible by sending PWM signals to the LED.
Be sure to check out the project write-up for more information, including the Arduino code!
September 3rd, 2017 at 15:37:58
This is not color detection.
Tihs is light intensity detection.
This has nothing to do with color!
Don’t fool yourself or us.
This is very stupid.
September 3rd, 2017 at 16:26:29
Yet it works – apparently you don’t know colour detection works (hint: absorption).
Since you are obviously not ‘very stupid’, how about you show us how it’s really done.
September 5th, 2017 at 08:53:06
Something is very fishy here. From what I know, that is a photorezistor. That being said, I am pretty sure it can only read the intensity of light.
I used the Serial Monitor and it confirmed my theory.
The board receives voltage between 1 and 5V. Inside the board, it is converted to numbers ranging from 0 to 1023
How in the word did you make it read the colour?
September 7th, 2017 at 12:29:27
Every different color in the light spectrum has a different light intensity, so that is what allows the photoristor to detect the color of the light. That is why a red led in a dark room will seem darker than a white led.
September 9th, 2017 at 02:31:28
This is a clever idea but it does not work as advertised. LEDs produce light in a very narrow portion of the spectrum. With red, green, and blue LEDs there are gaps in the spectrum of light projected on the target. If the target only reflects light in one of the gaps in the LED light then the target will appear black. That is why commercial color measuring systems use broad spectrum incandescent or Xenon lamps.
September 9th, 2017 at 02:38:33
Also, the light intensity as a function of color (wave length) is at the individual photon level. The LEDs give off a gazillion photons. The “intensity” the photo resistor measures is a combination of the photon energy lev el, the number of photons hitting the sensor, and the sensitivity profile of the photo resistor.
September 9th, 2017 at 16:44:25
SUBSCRIBE TO ME ON YOUTUBE MY USERNAME IS Ethicz SUBSCRUK AOT BA IHROAHIAHAOOAHIEAAAAA
September 14th, 2017 at 20:44:06
September 16th, 2017 at 05:37:58
People need to spend more time doing and less time thinking about how it ‘should work’ and commenting.
Look at the screen in front of you. See all those yellows & oranges and purple etc? They don’t exist, only red, green and blue (RGB) do.
Take a magnifying glass and look at your screen, these is only RGB there. The camera used to take these photos can only detect RGB, it doesn’t have any yellow or purple detectors.
Same with your eyes. You have three types of cones to detect light, you guessed it – RGB.
If you shine light at an object, it will absorb some wavelengths and reflect others. A black object reflects nothing, and white reflects everything. Purple will reflect red & blue, yellow will reflect red & green.
So if you cycle through each LED in sequence and record the intensity of the light coming back, you can determine the colour. For a purple object you will record low green and high red & blue, while yellow will record low blue but high red & green values.
Yes it will be inaccurate due to the narrow wavelength of LEDs etc, but what more do you want from a 5 cent detector?
Some commercial detectors work this way, others use white light and an RGB detector.
September 26th, 2017 at 03:04:14
DemonBolt, it reads each color separately, red then green then blue, and gets the returned level for each color thus 1024x1024x1024 levels.