Main Content

Color Sensors

To connect from the MATLAB® software to the EV3 Color Sensor (item number 45506), use the colorSensor function to create a colorSensor object.

  • To get the color of an object in front of the sensor, use the readColor function with the colorSensor object. The sensor evaluates the color of the object in from of the sensor and returns one of the following values: black, blue, brown, green, red, white, yellow, or no color. For example, you can use this capability to sort colored objects.

  • To measure reflected light intensity, use the readLightIntensity function with the colorSensor object, and set the mode to reflected. In this mode, the sensor emits red light, and measures the amount of light nearby objects reflect back to the sensor. It represents this measurement as a range, from 0 to 100 (dark to light). For example, you can use this capability to detect a dark line on a light surface.

  • To measure ambient light intensity, use the readLightIntensity function with the colorSensor object, and set the mode to ambient. In this mode, the sensor measures the amount of light it receives from the surrounding environment. It represents this measurement as a range, from 0 to 100 (dark to light). For example, you can use this capability to measure sunlight, or to detect when someone turns a light off.

See Also

| |