As with the two sensors we have covered so far, the color sensor can be used as a condition for the wait block, the switch block or the loop block. The color sensor, as well as the ultrasonic sensor, has several modes, but today we will be looking at the color mode.
- 30 Mar 2018
- LEGO MINDSTORMS
- Light and Color Sensor, Physics, Basic, Classes with students
- I.Bozhilov, A.Pavlov, С.Матинян, М.Кирилов, А.Павлов
If you put a wait block on the canvas, then from the drop-down menu select Color Sensor and then "Compare", you will see the three available modes:
Color - If you choose that mode, the sensor will evaluate the color of an object. We use that mode for solving the Rubik's cube, for sorting balls, for programming color code, etc. The diode of the sensor emits red, green and blue light. Depending on the intensity of the reflected light in each of the three light spectrums, the robot can differentiate 8 colors. Each color is encoded as a number:
0= No color;
As with every other sensor, we start with the port number the sensor is connected to. This is shown by the number in the upper right corner of the block and by default the port is 3. Afterwards, from the first (and only) field we choose upon which color to wait. Note that you can choose more than one color, hence wait for more than one color. So, for instance, if we want to go forward until we detect a red or black line, we just need to select 1 and 5.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons