Controller Sensing#

For Controller Sensing blocks to appear in VEXcode, a V5 Controller must first be connected to VEXcode V5.

Refer to these articles for more information:

Controller Pressed#

The Controller Pressed block is used to report if a button on the V5 Controller is pressed.

<[Controller1 v] [Up v] pressed?>

The Controller Pressed block reports True when the selected Controller button is pressed.

The Controller Pressed block reports False when the selected Controller button is not pressed.

Choose which Controller to use.

Image of a V5 Controller with a pressed button, indicating the current state of the controller.

Choose which Controller button to use.

Image of a V5 controller button being pressed, indicating user interaction with the device.

In this example, the Brain will print a message on its screen the first time the X button on the controller is pressed.

  when started :: hat events
  [Don't do anything until the X button is pressed.]
  wait until <[Controller1 v] [X v] pressed? :: #5cb0d6>
  print [The X button was pressed.] on [Brain v] ◀ and set cursor to next row

Position of Controller#

The Position of Controller block is used to report the position of a joystick on the V5 Controller along an axis.

  (Controller [1 v] position)

The Position of Controller block reports a range from -100 to 100.

The Position of Controller block reports 0 when the joystick axis is centered.

Choose the joystick’s axis.

Diagram illustrating the controller position axis for V5 Brain sensing and motor control systems.

In this example, the Brain will print the 3rd axis of the V5 Controller’s joysticks.

  when started :: hat events
  print (Controller [3 v] position) on [Brain v] ◀ and set cursor to next row

Controller Enable/Disable#

The Controller Enable/Disable block is used to enable or disable Controller configured actions from the Devices menu.

  Controller [Disable v]

Choose to either enable or disable the configured Controller actions. By default, the Controller is Enabled at the start of every project.

Image of V5 Brain controller interface displaying timer, battery status, and cursor position on touchscreen.

In this example, the Controller will be disabled at the start of the project and be re-enabled after the drivetrain has moved forward for 6 inches.

  when started :: hat events
  Controller [Disable v]
  drive [forward v] for (6) [inches v] ▶
  Controller [Enable v]