Connection to color sensor


This object represents a connection to an EV3 Color Sensor (item number 45506). To connect to the color sensor, create this object using the colorSensor function. To read color and light intensity, use this object with the functions listed in Object Functions.


Before creating an object, complete the steps described in Connections to EV3 Hardware.

Use legoev3 to connect to, and create an object that represents, the EV3 brick. For example:

myev3 = legoev3;

Use colorSensor to connect to, and create an object that represents, a color sensor. For example:

mycolorsensor = colorSensor(myev3)
mycolorsensor = 

  colorSensor with properties:

    InputPort: 3

To get data from the sensor, use the colorSensor object with readColor and readLightIntensity. For example:

ans =



expand all

This property is read-only.

Number of the EV3 input port that the sensor uses, returned as a double.

Example: 1

Data Types: double

Object Functions

colorSensorCreate connection to color sensor
readColorRead color of object in front of color sensor
readLightIntensityRead intensity of light that reaches color sensor