Sensor óptico#
Introducción#
La categoría de Detección Óptica incluye bloques que controlan y recuperan datos del sensor óptico VEX IQ. Este sensor puede detectar objetos, identificar colores y medir el brillo y el tono.
A continuación se muestra una lista de todos los bloques:
configurar luz óptica — Enciende o apaga la luz del sensor óptico.
establecer potencia de luz óptica — Establece el brillo de la luz del sensor óptico.
Optical found an object? — Reports whether an object is detected.
Optical detects color? — Reports whether a specific color is detected.
Optical color name — Reports the name of the color detected.
Optical brightness — Reports the brightness detected by the sensor.
Optical hue — Reports the hue value of the detected color.
When Optical — Runs the attached stack of blocks when the Optical Sensor detects or loses an object.
establecer luz óptica#
The set Optical light stack block turns the light on the Optical Sensor on or off. The light lets the Optical Sensor see objects better if it is looking at an object in a dark area.
conjunto [Optical 1 v] luz [encendido v]
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
estado |
The state of the Optical Sensor’s light to set:
|
Ejemplo
cuando empezó
[Repeatedly flash the Optical Sensor's lights.]
para siempre
conjunto [Optical 1 v] luz [encendido v]
esperar (1) segundos
conjunto [Optical 1 v] luz [apagado v]
esperar (1) segundos
establecer potencia de luz óptica#
The set Optical light power stack block sets how bright the Optical Sensor’s light is. The light can help the Optical Sensor detect objects and colors more clearly.
A higher percentage makes the light brighter. A lower percentage makes the light dimmer.
If the Optical Sensor’s light is off, setting the light power above 0% will turn the light on.
If the Optical Sensor’s light is on, setting the light power at 0% will turn the light off.
set [Optical1 v] light power to (50)%
Nota: Si la luz del sensor óptico está apagada, este bloque encenderá la luz.
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
brillo |
El brillo de la luz del sensor óptico de 0 a 100 como porcentaje. |
Ejemplo
cuando empezó
[Repeatedly change the brightness of the Optical Sensor's lights.]
para siempre
set [Optical1 v] light power to (10)%
esperar (2) segundos
set [Optical1 v] light power to (50)%
esperar (2) segundos
set [Optical1 v] light power to (100)%
esperar (2) segundos
¿El sistema óptico detectó algún objeto?#
The Optical found an object? Boolean block reports whether the Optical Sensor detects an object within range.
True — The Optical Sensor has detected an object.
False — The Optical Sensor has not detected an object.
<[Optical 1 v] Encontraste un objeto?>
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
Ejemplo
cuando empezó
[Turn until the Optical Sensor detects an object.]
establecer la velocidad de giro a (10) [% v]
set [Optical1 v] light power to [75]%
turno [derecha v]
esperar hasta <[Optical 1 v] Encontraste un objeto?>
imprimir [Object detected] en la pantalla ◀ y coloque el cursor en la siguiente fila
deja de conducir
¿La tecnología óptica detecta el color?#
The Optical detects color? Boolean block reports whether the Optical Sensor detects a specific color.
True — The Optical Sensor has detected the specified color.
False — The Optical Sensor has not detected the specified color.
<[Optical 1 v] detecta [rojo v]?>
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
color |
Which color to check for:
|
Ejemplo
cuando empezó
[Turn until the Optical Sensor detects a red object.]
establecer la velocidad de giro a (10) [% v]
set [Optical1 v] light power to [75]%
turno [derecha v]
esperar hasta <[Optical 1 v] detecta [rojo v]?>
imprimir [Red detected] en la pantalla ◀ y coloque el cursor en la siguiente fila
deja de conducir
Nombre del color óptico#
The Optical color name reporter block reports the name of the color detected by the Optical Sensor.
Los colores posibles son:
red
green
blue
yellow
orange
purple
cyan
Nota: Este bloque se puede insertar en el bloque establecer color del LED táctil para que el LED táctil coincida con el color detectado.
([Optical 1 v] nombre de color)
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
Ejemplo
cuando empezó
[Display a message when the Optical Sensor detects red.]
esperar hasta <[Optical 1 v] detecta [rojo v]?>
imprimir ([Optical 1 v] nombre de color) en la pantalla ◀ y coloque el cursor en la siguiente fila
Brillo óptico#
The Optical brightness reporter block reports how bright the detected light is, as a percentage from 0% to 100%.
A higher percentage means the Optical Sensor detects more light. A lower percentage means the Optical Sensor detects less light.
([Optical 1 v] brillo en %)
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
Ejemplo
cuando empezó
[Display the brightness when the Optical Sensor detects red.]
esperar hasta <[Optical 1 v] detecta [rojo v]?>
imprimir ([Optical 1 v] brillo en %) en la pantalla ◀ y coloque el cursor en la siguiente fila
Tono óptico#
The Optical hue reporter block reports the hue detected by the Optical Sensor as a number from 0 to 359 degrees.
Hue is a way to describe color using numbers around a color wheel, as shown below:

([Optical 1 v] tono en grados)
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
Ejemplo
cuando empezó
[Print when the Optical Sensor detects pink.]
para siempre
pantalla clara
Coloque el cursor en la fila (1) columna (1) en la pantalla
si <<([Optical 1 v] tono en grados) [math_greater_than v] [290]> y <([Optical 1 v] tono en grados) [math_less_than v] [350]>> entonces
imprimir [Pink!] en la pantalla ▶
esperar (0.1) segundos
demás
imprimir [Not pink.] en la pantalla ▶
esperar (0.1) segundos
Cuando Óptico#
The When Optical hat block runs the attached stack of blocks when the selected Optical Sensor detects or loses an object.
cuando [Optical 1 v] [detects v] un objeto
Parámetros |
Descripción |
|---|---|
sensor óptico |
Qué sensor óptico utilizar, configurado en la ventana Dispositivos. |
estado |
When the attached stack of blocks will run:
|
Ejemplo
cuando [Optical 1 v] [detects v] un objeto
[Find an object when it is lost.]
turno [derecha v]
esperar hasta <[Optical 1 v] Encontraste un objeto?>
deja de conducir