Color Sensor
Detect color, reflected light, or ambient light using EV3 brick
Add-On Required: This feature requires the Simulink Support Package for LEGO MINDSTORMS EV3 Hardware add-on.
Libraries:
Simulink Support Package for LEGO MINDSTORMS EV3 Hardware
Description
Use the Color Sensor block to detect the color of an object, measure reflected light, or measure ambient light using a color sensor connected to the LEGO® MINDSTORMS® EV3 brick.
During simulations without hardware, this block emits zeros. See Block Produces Zeros or Does Nothing in Simulation.
Ports
Output
Color — Color data
color mode, color intensity
The block outputs color data the sensor detects of an object or its surrounding.
Dependencies
The block outputs these color values based on the mode you select.
Color
— The block outputs the color of an object.Reflected light intensity
— The block outputs color intensity of an object.Ambient light intensity
— The block outputs ambient light intensity of the surrounding.
Data Types: uint8
Parameters
EV3 brick input port — Input port number of EV3 brick
1
(default) | 2
| 3
| 4
Select the EV3 brick input port to which the color sensor is connected. Avoid assigning multiple devices to the same input port.
Mode — Light detection mode of sensor
Color
(default) | Reflected light intensity
| Ambient light intensity
Select the light detection mode of the sensor that is connected to the EV3 brick.
Color
— In this mode, the sensor evaluates the color of an object and outputs one of these values on the output port of the block.0
— Indicates that the sensor detects no color.1
— Indicates that the sensor detects the color black.2
— Indicates that the sensor detects the color blue.3
— Indicates that the sensor detects the color green.4
— Indicates that the sensor detects the color yellow.5
— Indicates that the sensor detects the color red.6
— Indicates that the sensor detects the color white.7
— Indicates that the sensor detects the color brown.
For example, you can use this mode for EV3-based robots to solve Rubik's cube puzzles.
Reflected light intensity
— In this mode, the sensor flashes the LED and measures the amount of light reflected on the nearby surfaces. The block outputs values from0
to100
where0
indicates a dark surface and100
indicates a light surface. For example, you can use this mode for EV3-based robots that to detect and follow a black line around an obstacle course.Ambient light intensity
— In this mode, the sensor measures the surrounding ambient light. The block outputs values from0
to100
where0
indicates a dark surrounding ambience and100
indicates a bright surrounding ambience. For example, you can use this mode for EV3-based robots to follow a light source.
Sample time — Time interval at which block reads sensor values
0.1
(default) | positive integer
Specify the frequency of how often the block reads values from the sensor connected
to the EV3 brick. Shorter sample times, such as 0.01
, may produce
unreliable measurements.
Smaller sample times require the processor to complete the same number of instructions in less time, which can cause task overruns.
Version History
Introduced in R2012a
See Also
External Websites
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)