Color Sensor#
Introduction#
The Color Sensor category includes blocks that report color-based information from a VEX IQ Color Sensor. These blocks allow your robot to detect when an object is present, recognize specific colors, and return visual data such as brightness and hue.
You can also use blocks to configure the brightness of the sensor’s internal light. These tools are ideal for programs that need to react to colored objects, lighting conditions, or sensor feedback in real time.
Below is a list of all blocks:
set Color light — Sets the brightness of the Color Sensor’s light.
Color found an object? — Returns whether any object is detected.
Color detects color? — Returns whether a specific color is detected.
Color color name — Returns the name of the detected color.
Color brightness — Returns detected brightness as a percentage.
Color hue — Returns the hue angle of the detected color.
set Color light#
The set Color light block sets the brightness of the Color Sensor’s light.
Establezca la luz [Color 1 v] al (50)%
Parameters |
Description |
|---|---|
color sensor |
Which Color Sensor’s light brightness to set, configured in the Devices window. |
brightness |
The brightness of the light from 0 to 100 as a percent. |
Example
cuando empezó
[Light up the Color Sensor dimmer.]
Establezca la luz [Color 1 v] al (25)%
esperar (2) segundos
[Light up the Color Sensor brighter.]
Establezca la luz [Color 1 v] al (100)%
Color found an object?#
The Color found an object block returns a Boolean indicating whether the Color Sensor has detected any object.
True — The Color Sensor has detected an object.
False — The Color Sensor has not detected an object.
<[Color 1 v] Encontraste un objeto?>
Parameters |
Description |
|---|---|
color sensor |
Which Color Sensor to use, configured in the Devices window. |
Example
cuando empezó
[Print a different message when an object is in front of the Color Sensor.]
para siempre
Coloque el cursor en la fila (1) columna (1) de [Brain v]
si <[Color 1 v] Encontraste un objeto?> entonces
imprimir [Object detected] en [Brain v] ▶
demás
imprimir [Nothing detected] en [Brain v] ▶
fin
Limpiar la fila (1) en [Brain v]
Color detects color?#
The Color detects color block returns a Boolean indicating whether the Color Sensor has detected a specific color.
True — The Color Sensor has detected the specified color.
False — The Color Sensor has not detected the specified color.
<[Color 1 v] detecta [rojo v]?>
Parameters |
Description |
|---|---|
color sensor |
Which Color Sensor to use, configured in the Devices window. |
color |
Which color to check for:
|
Example
cuando empezó
[Turn until the Color Sensor detects green.]
turno [derecha v]
esperar hasta <[Color 1 v] detecta [verde v]?>
deja de conducir
Color color name#
The Color color name block returns the name of the color detected by the Color Sensor.
Possible colors are:
red
green
blue
white
yellow
orange
purple
red violet
violet
blue violet
blue green
yellow green
yellow orange
red orange
Note: This block can be inserted into the set Touch LED color block to make the Touch LED match the detected color.
([Color 1 v] nombre de color)
Parameters |
Description |
|---|---|
color sensor |
Which Color Sensor to use, configured in the Devices window. |
Example
cuando empezó
[Stop and print when the Color Sensor detects green.]
turno [derecha v]
esperar hasta <[Color 1 v] detecta [verde v]?>
deja de conducir
imprimir ([Color 1 v] nombre de color) en [Brain v] ◀ y coloque el cursor en la siguiente fila
Color brightness#
The Color brightness block returns the amount of light detected by the Color Sensor in a range from 0% to 100%.
([Color 1 v] brillo en %)
Parameters |
Description |
|---|---|
color sensor |
Which Color Sensor to use, configured in the Devices window. |
Example
cuando empezó
[Stop and print the brightness when the Color Sensor detects green.]
turno [derecha v]
esperar hasta <[Color 1 v] detecta [verde v]?>
deja de conducir
imprimir ([Color 1 v] brillo en %) en [Brain v] ◀ y coloque el cursor en la siguiente fila
Color hue#
The Color hue block returns the hue value of the color detected by the Color Sensor.
Hue values range from 0 to 359 degrees, corresponding to positions on the color wheel shown below.

([Color 1 v] tono en grados)
Parameters |
Description |
|---|---|
color sensor |
Which Color Sensor to use, configured in the Devices window. |
Example
cuando empezó
[Print when the Color Sensor detects pink.]
para siempre
borrar todas las filas en [Brain v]
Coloque el cursor en la fila (1) columna (1) de [Brain v]
si <<([Color 1 v] tono en grados) [math_greater_than v] [290]> y <([Color 1 v] tono en grados) [math_less_than v] [350]>> entonces
imprimir [Pink!] en [Brain v] ▶
esperar (0.1) segundos
demás
imprimir [Not pink.] en [Brain v] ▶
esperar (0.1) segundos