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.

The Optical Sensor has a light that can be turned on or off. The light can help the Optical Sensor detect objects and colors more clearly.

A continuación se muestra una lista de todos los bloques:

conjunto de 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:

  • on — Turns the light on.
  • off — Turns the light off.

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

ajuste de 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 la encenderá.

Parámetros

Descripción

sensor óptico

Qué sensor óptico utilizar, configurado en la ventana Dispositivos.

brillo

El brillo de la luz del sensor óptico, expresado en porcentaje de 0 a 100.

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

¿Detecta el color mediante tecnología óptica?#

The Optical detects color? block reports a Boolean indicating 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:

  • red – Hue value between 341° and 20°.
  • green - Hue value between 81° and 140°.
  • blue - Hue value between 200° and 240°.
  • yellow - Hue value between 41° and 60°.
  • orange
  • purple - Hue value between 281° and 320°.
  • cyan - Hue value between 141° and 200°.

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

Tonalidad óptica#

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.

Una rueda de colores circular que muestra un espectro completo de tonalidades etiquetadas con valores de grados alrededor del perímetro, aumentando en incrementos de 30 grados desde 0° en la parte superior hasta 360°.

([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

Which action to trigger the hat block:

  • detects — The Optical Sensor detects an object.
  • loses — The Optical Sensor lost sight of an object.

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