Controlador#

Introducción#

The Controller category includes blocks for detecting and responding to input from the VEX IQ (2nd gen) Controller. These blocks allow your robot to react to button presses, monitor joystick positions, and control how input mappings are applied during a project.

Below is a list of all blocks:

¿Botón del controlador presionado?#

El bloque ¿Botón del controlador presionado? devuelve un entero que indica si se está presionando un botón del controlador específico.

  • 0 — The controller button is not being pressed.

  • 1 — The controller button is being pressed.

A front and back side view of the IQ 2nd gen Controller with all buttons highlighted yellow. The surface of the controller contains two joystick buttons in the upper left and right corners, with E up and down below the left joystick and F up and down below the right. On the back of the controller are L up and down and R up and down on the left and right sides respectively.
<¿Controlador [E ▲ v] presionado?>

Parámetros

Descripción

botón

El botón para verificar si se presionó o soltó:

  • E ▲
  • E ▼
  • F ▲
  • F ▼
  • L ▲
  • L ▼
  • R ▲
  • R ▼
  • L3
  • R3

Ejemplo

cuando empezó
[Move forward when the R ▲ button is pressed.]
para siempre
si <¿Controlador [R ▲ v] presionado?> entonces
unidad [adelante v]
demás
deja de conducir

posición del eje del controlador#

El bloque posición del eje del controlador devuelve la posición del joystick a lo largo de un eje especificado como un número entero de -100 a 100.

The IQ 2nd gen Controller with the four joystick axes highlighted. On the left joystick, Axis A is vertical and Axis B is horizontal. On the right joystick, Axis C is horizontal and Axis D is vertical.
(Posición [A v] del controlador)

Parámetros

Descripción

eje

El eje para verificar el cambio:

  • A
  • B
  • C
  • D

Ejemplo

cuando empezó
[Turn depending on the position of the right joystick.]
para siempre
si <(Posición [C v] del controlador) [math_less_than v] [0]> entonces
turno [izquierda v]
de lo contrario si <(Posición [C v] del controlador) [math_greater_than v] [0]> entonces
turno [derecha v]
demás
deja de conducir

habilitar/deshabilitar el controlador#

The controller enable/disable block enables or disables controller configured actions from the Devices menu.

Controlador [Disable v]

Parámetros

Descripción

estado

En qué estado establecer el controlador:

  • Deshabilitar
  • Habilitar

Ejemplo

cuando empezó
[Disable controller configured actions until drive is done.]
Controlador [Disable v]
unidad [adelante v] para (6) [pulgadas v] ▶
Controlador [Enable v]

cuando el botón del controlador#

El bloque cuando se presiona el botón del controlador activa la pila de bloques adjunta cuando se presiona o se suelta el botón.

A front and back side view of the IQ 2nd gen Controller with all buttons highlighted yellow. The surface of the controller contains two joystick buttons in the upper left and right corners, with E up and down below the left joystick and F up and down below the right. On the back of the controller are L up and down and R up and down on the left and right sides respectively.
cuando el botón del controlador [E ▲ v] [presionado v]

Parámetros

Descripción

botón

El botón para verificar si se presionó o soltó:

  • E ▲
  • E ▼
  • F ▲
  • F ▼
  • L ▲
  • L ▼
  • R ▲
  • R ▼
  • L3
  • R3

estado del botón

Especifica si se debe activar la pila de bloques adjunta cuando el botón está:

  • presionado
  • liberado

Ejemplo

cuando el botón del controlador [R ▲ v] [presionado v]
[Turn when a button is pressed.]
girar [derecha v] por (90) grado ▶

cuando se cambia el eje del controlador#

El bloque cuando se cambia el eje del controlador activa la pila de bloques adjunta cuando se cambia el eje.

The IQ 2nd gen Controller with the four joystick axes highlighted. On the left joystick, Axis A is vertical and Axis B is horizontal. On the right joystick, Axis C is horizontal and Axis D is vertical.
Cuando se cambia el eje [A v] del controlador

Parámetros

Descripción

eje

El eje para verificar el cambio:

  • A
  • B
  • C
  • D

Ejemplo

Cuando se cambia el eje [D v] del controlador
[Move forward when right joystick is moved.]
unidad [adelante v] para (200) [mm v] ▶