Controller#

Introduction#

The One Stick Controller features a 4-button layout and a joystick that functions as both an analog input and a pressable button. These inputs allow the robot to detect button presses and joystick movements, enabling interactive and responsive control. Below is a list of all available blocks:

controller button pressed?#

The controller button pressed? block returns an integer indicating whether a specific controller button is being pressed.

  • 0 - The controller button is not being pressed.

  • 1 - The controller button is being pressed.

VEX AIM One Stick Controller with a joystick on the left and four buttons to the right arranged like a clock face with the buttons at 12, 3, 6, and 9 o' clock.

The Controller button pressed Boolean block.#
    <controller button [up v] pressed?>

Parameters

Description

button

The button to check if it has been pressed:

  • up
  • down
  • left
  • right
  • stick

Example

  when started :: hat events
  [Move forwards while the Up button is being pressed.]
  forever
  if <controller button [up v] pressed?> then
  move [forward v]
  else
  stop all movement

controller axis position#

The controller axis position block returns the position of the joystick along a specified axis as an integer from -100 to 100.

VEX AIM Controller with a joystick on the left and four buttons to the right arranged like a clock face with the buttons at 12, 3, 6, and 9 o' clock.

The Controller axis position reporter block.#
    (controller axis [1 v] position)

Parameters

Description

axis

The axis to return the position of:

  • 1
  • 2

Example

  when started :: hat events
  [Move forward when the joystick is moved up.]
  forever
  if <(controller axis [1 v] position) [math_greater_than v] [0]> then
  move [forward v]
  else
  stop all movement

when controller button#

The when controller button block activates the attached stack of blocks when the button is being pressed or released.

VEX AIM One Stick Controller with a joystick on the left and four buttons to the right arranged like a clock face with the buttons at 12, 3, 6, and 9 o' clock.

The When Controller button hat block.#
    when controller button [up v] [pressed v] :: hat events

Parameters

Description

button

The button to check for a press or release:

  • up
  • down
  • left
  • right
  • stick

button status

Specifies whether to trigger the attached stack of blocks when the button is:

  • pressed
  • released

Example

  when controller button [up v] [pressed v] :: hat events
  [Kick hard when Up button is pressed.]
  kick object [hard v]

when controller axis is changed#

The when controller axis is changed block activates the attached stack of blocks when the axis is being changed.

VEX AIM Controller with a joystick on the left and four buttons to the right arranged like a clock face with the buttons at 12, 3, 6, and 9 o' clock.

The When Controller axis is changed hat block.#
    when controller axis [1 v] is changed :: hat events

Parameters

Description

axis

The axis to check for change:

  • 1
  • 2

Example

  when controller axis [1 v] is changed :: hat events
  [Move forward when the joystick is moved.]
  move [forward v] for [50] [mm v] ▶