Controller#

Introduction#

The VEX AIM One Stick Controller has four buttons and a joystick. The joystick can be moved along two axes and can also be pressed like a button.

Controller blocks can be used to check button presses, read joystick movement, or run blocks when controller events happen.

Below is a list of all blocks:

Values — Check controller button status or read joystick position.

Actions — Run blocks when controller input changes.

Values#

controller button pressed?#

The controller button pressed? Boolean block returns whether a selected 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.

controller button pressed? Boolean block#
    <controller button [▲ v] pressed?>

Parameter

Description

button

The button to check:

  • stick

Example

When started, moves forward while the ▲ button is pressed.#
  when started
  [Move forward while the ▲ button is pressed.]
  forever
    if <controller button [▲ v] pressed?> then
      move [forward v]
    else
      stop all movement
    end
  end

controller axis position#

The controller axis position reporter block returns the joystick position along a selected axis as a number 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.

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

Parameter

Description

axis

The joystick axis to report: 1 (up and down) or 2 (left and right).

Example

When started, moves forward when the joystick is moved up.#
  when started
  [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
    end
  end

Actions#

when controller button#

The when controller button Hat block runs the attached stack when a selected controller button is 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.

when controller button Hat block#
    when controller button [▲ v] [pressed v]

Parameter

Description

button

The button to check:

  • stick

button status

The button event that triggers the attached stack: pressed or released.

Example

When the ▲ button is pressed, kicks an object with hard force.#
  when controller button [▲ v] [pressed v]
  [Kick hard when the ▲ button is pressed.]
  kick object [hard v]

when controller axis is changed#

The when controller axis is changed Hat block runs the attached stack when a joystick’s position changes along the selected axis.

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.

when controller axis is changed Hat block#
    when controller axis [1 v] is changed

Parameter

Description

axis

The joystick axis to check: 1 (up and down) or 2 (left and right).

Example

When the joystick’s position changes along controller axis 1, moves the robot forward 50 millimeters.#
  when controller axis [1 v] is changed
  [Move forward when the joystick's position changes along axis 1.]
  move [forward v] for [50] [mm v] ▶