Color Sensor
Detect colors, reflected light, or ambient light
Add-On Required: This feature requires the Simulink Support Package for LEGO MINDSTORMS EV3 Hardware add-on.
Library
Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware
Description
Detect the color of an object, measure reflected light, or measure ambient light.
The block output emits values as uint8.
During simulations without hardware, this block emits zeros. See Block Produces Zeros or Does Nothing in Simulation.
Parameters
- EV3 brick input port
Identify the EV3 brick input port connected to this sensor. Avoid assigning multiple devices to the same port. The options are
1
,2
,3
, or4
.- Mode
Select the type of measurement to perform,
Color
(the default),Reflected light intensity
, orAmbient light intensity
.With
Color
, the sensor evaluates the color of an object and outputs one of the following values:0
= No Color1
= Black2
= Blue3
= Green4
= Yellow5
= Red6
= White7
= Brown
For example, there are EV3-based robots that use
Color
mode solve Rubik’s cube puzzles.With
Reflected light intensity
, the sensor shines an LED and measures the amount of light reflected by nearby surfaces. The block outputs a normalized value (0-100, dark to light). For example, there are EV3 robots that use this mode to detect and follow a black line around an obstacle course.With
Ambient light intensity
, the sensor measures the amount of light in its surroundings. The block outputs a normalized value (0-100, dark to light). For example, there are EV3 robots that use this mode to follow a light source.- Sample time
Specify how often the block reads sensor values.
Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.