The color sensors supports different modes of working. In this video we are working with the Reflected light, which is not actually the detected color. Most robotics sensors actually work with reflected light and you should definitely learn how to use this mode.
- # 151
- 27 Oct 2015
The sensor emits light. Part of this light is reflected and returned back to the sensor. The reflected light could be in the range of 0 to 100% (at least theoretically). The bright colors reflect a greater percentage of the light that the dark colors. Since the light is red, then a red surface should return the lowest value.
The next thing that I would like to discuss about the color sensor is to enter into more details on how exactly does the color sensor work and the options of the block when programming which means that we can program it for color, for reflected light and how does it work for reflected light.
When you click at a wait block that is waiting for the color sensor you can see in the menu that you can compare a color and second option reflected light. What's the difference between the 2 options? Color detects the color over which the robot is. The reflected light is more simple and it only gives you one number which tells you how much of the light got reflected back from the surface.
For example, the sensor emits a 100% light and part of this light gets reflected and gets returned back to the sensor. If we are over some bright color more of the light will return. If we are over some dark color less of the light will return. Let's check this. Currently I'll select to see the reflected light and
I'm currently over the bright table and I see that about 19% of the light gets reflected and this is what this arrow here means that is gets reflected from the surface, 19%. If I move the robot over the black line
we can see that about 5% of the light gets reflected. This is how we can distinguish bright from dark colors. This values might be different from your sensor, it depends on the calibration but I'm not going to enter into details about the calibration. For the moment what you need to know is that the sensor emits light, part of this light gets reflected, received from the sensor and depending on how much light is reflected you can know the color of the surface over which the robot is. We'll change our program in the following way. We move forward until we detect a surface that reflects about 90% of the light so only 10% of the light gets back to the sensor less than 10%, which means black, then we stop, move forward until color sensor, we are somewhere over a surface that reflects more light and more light gets back to the sensor, about more than 10% of the light.
These are our threshold values, so black is something below 10%, bright is something above 10%. The specific values might be different for your robot, you must try them out to see what are the values, in my case in our robot, these are 5 and 19 and the middle between 5 and 19 is about 10. Let's see if our program works. Downloading and running the program.
As you can see the program behaves in the same way only this time it is not using the color of the Mindstorms EV3 color sensor but it's using the detected reflected light. Part of the light gets reflected from the surface of the table and return back to the sensor. We are using this reflected light to know what the color of the surface is. This here was a short and small introduction in the color sensor and how we can use it. In some of the next videos we'll enter into more detail. We've also built other videos. Now let's try a few program that you can use at home or in the classroom to experiment with the color sensor.