How to program the EV3 color sensor Pro Preview

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.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #812
  • 30 Mar 2018

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;
    1 = Black;
    2 = Blue;
    3 = Green;
    4 = Yellow;
    5 = Red;
    6 = White;
    7 = Brown;

 

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

Image for Instructors Remote Training
  • 136
  • 280:11
  • 156
Image for Color Sensor
  • 9
  • 0
  • 4
  • 3d_rotation 0
Image for Level B2. "Military Technologies". Robotics with LEGO
  • 37
  • 6:37
  • 111
Image for Lesson 1 - Color Sensor
  • 11
  • 3
  • 5
  • 3d_rotation 2
Image for Robotics with LEGO - Level 1.5 - Spy games
  • 56
  • 12:47
  • 135