Sensor óptico#

Introducción#

El Sensor Óptico V5 detecta el color, el brillo y la presencia de objetos cercanos mediante una combinación de un sensor de color RGB y un sensor de proximidad. También puede usar su LED integrado para iluminar objetos y lograr una detección más precisa.

El sensor óptico VEX V5.

A continuación se muestra una lista de bloques disponibles:

Establecer luz óptica#

The set Optical light stack block turns the Optical Sensor’s LED on or off. This can help increase the sensor’s accuracy when detecting colors.

conjunto [Optical 1 v] luz [encendido v]

Parámetros

Descripción

dispositivo

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

estado

The state of the Optical Sensor’s light: on or off.

cuando empezó
[Turn on the sensor's LED.]
conjunto [Optical 1 v] luz [encendido v]

Establecer potencia de luz óptica#

The set Optical light power stack block sets the brightness of the Optical Sensor’s LED. 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.

Establezca la potencia de luz [Optical 1 v] al [50]%

Parámetros

Descripción

dispositivo

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

brillo

The brightness to set the Optical Sensor’s light to, from 0% to 100%. Use whole numbers.

cuando empezó
[Turn on the sensor's LED at half brightness.]
Establezca la potencia de luz [Optical 1 v] al [50]%

Optical found an object#

The Optical found an object Boolean block reports whether or not the Optical Sensor detects an object within range.

  • True — The Optical Sensor detects an object.

  • False — The Optical Sensor does not detect an object.

<[Optical 1 v] Encontraste un objeto?>

Parámetros

Descripción

dispositivo

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

Ejemplo

Conduzca hacia adelante hasta que se detecte un objeto#
cuando empezó
[Drive forward until an object is found.]
unidad [adelante v]
esperar hasta <[Optical 1 v] Encontraste un objeto?>
deja de conducir

Optical detects color#

The Optical detects color Boolean block reports whether the Optical Sensor detects a specified color, based on the detected hue value.

  • True – The sensor detects the specified color.

  • False – The sensor does not detect the specified color.

Note: The Optical Sensor is looking for hue ranges that match the specified color. For detecting specific hue ranges, see the Optical hue reporter block.

<[Optical 1 v] detecta [rojo v]?>

Parámetros

Descripción

dispositivo

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

color

Which color to look for:

  • red – A detected hue value between 340° - 20°.
  • green – A detected hue value between 80° - 140°.
  • blue – A detected hue value between 200° - 240°.
  • yellow – A detected hue value between 40° - 60°.
  • orange – A detected hue value between 20° - 40°.
  • purple – A detected hue value between 240° - 280°.
  • cyan – A detected hue value between 140° - 200°.

Ejemplo

Avanza hasta que se detecte el color rojo.#
cuando empezó
[Drive forward until red is found.]
unidad [adelante v]
esperar hasta <[Optical 1 v] detecta [rojo v]?>
deja de conducir

Brillo óptico#

The Optical brightness reporter block reports how much light is reflected back to the Optical Sensor, as a percentage from 0% to 100%.

A higher percentage means more light is reflected back to the Optical Sensor. A lower percentage means less light is reflected back.

([Optical 1 v] brillo en %)

Parámetros

Descripción

dispositivo

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

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.

La rueda de colores VEX que muestra los grados de los colores alrededor de un círculo, con el rojo en 0 grados y en transición a través del arco iris a medida que aumenta el valor.

([Optical 1 v] tono en grados)

Parámetros

Descripción

dispositivo

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

Ejemplo

cuando empezó
[Look for the color pink using hue.]
para siempre
pantalla clara
Coloque el cursor en la fila [1] columna [1] en la pantalla
si <[300] [math_less_than v] ([Optical 1 v] tono en grados) [math_less_than v] [359]> entonces
imprimir [This is pink!] en la pantalla ▶
demás
imprimir [No pink detected!] en la pantalla ▶

Cuando óptico#

The when Optical hat block runs the attached stack of blocks whenever the Optical Sensor detects or loses an object.

cuando [Optical 1 v] [detects v] un objeto :: hat events

Parámetros

Descripción

dispositivo

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

estado

When the attached stack of blocks will run: detects runs when an undetected object is detected, while loses runs when a detected object is now no longer detected.