Controller#

Introduction#

The VEX AIR Drone Controller features a 12-button layout and two joysticks. These inputs allow the drone 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 Boolean block reports if a specific controller button is being pressed.

  • True — The specified button is being pressed.

  • False — The specified button is not being pressed.

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

A VEX AIR Drone Controller showing buttons 5 through 12. Buttons 5 and 6 are on the back of the right side of the controller, perpendicular to the joystick. Buttons 7 and 8 are in the same position on the left side. Buttons 9 through 12 are on the bottom surface of the controller, with 9 in the upper right corner above 10, and 11 in the upper left corner above 12.

Parameters

Description

button

The button to check if it has been pressed, ranging from 5 to 12.

Example

    when started
    [Take a picture when button 5 is pressed.]
    take off to [500] [mm v] ▶
    forever
        move with controller
        if <controller button [5 v] pressed?> then
            capture image on [forward v] camera
        end
    end

controller axis position#

The controller axis position reporter block reports the position of the specified joystick axis. This reports an integer from –100 to 100.

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

A VEX AIR Drone Controller with the joystick axes highlighted. Axis 1 and 2 are around the left joystick, and Axis 3 and 4 are around the right.

Parameters

Description

axis

The axis to report the position of:

  • 1 — The left joystick vertical axis.
  • 2 — The left joystick horizontal axis.
  • 3 — The right joystick horizontal axis.
  • 4 — The right joystick vertical axis.

Example

    when started
    [Climb when the left joystick is moved up.]
    take off to [500] [mm v] ▶
    forever
        if <(controller axis [1 v] position) [math_greater_than v] [0]> then
            climb [up v]
        else
            hover
    end

controller is connected#

The controller is connected Boolean block reports if the controller is connected to the drone.

  • True — The controller is connected.

  • False — The controller is not connected.

The Controller axis position reporter block.#
    <controller is connected to drone?>

Parameters

Description

This block has no parameters.

Example

    when started
    [Print controller connection status on screen.]
    forever
        if <controller is connected to drone?> then
            clear screen
            set cursor to row (1) column (1) on screen
            print [Controller connected] on screen ▶
            wait (0.5) seconds
        end
    end

controller battery level#

The controller battery level reporter block reports the battery level of the controller, as a percentage from 0% to 100%.

The Controller axis position reporter block.#
    (controller battery level in %)

Parameters

Description

This block has no parameters.

Example

    when started
    [Show controller's battery level.]
    if <(controller battery level in %) [math_greater_than v] [50]> then
        print [Battery level ok] on screen ▶
    else
        print [Battery level low] on screen ▶

when controller button#

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

The When Controller button hat block.#
    when controller button [5 v] [pressed v]

A VEX AIR Drone Controller showing buttons 5 through 12. Buttons 5 and 6 are on the back of the right side of the controller, perpendicular to the joystick. Buttons 7 and 8 are in the same position on the left side. Buttons 9 through 12 are on the bottom surface of the controller, with 9 in the upper right corner above 10, and 11 in the upper left corner above 12.

Parameters

Description

button

Determines which button will trigger the event, ranging from 5 to 12.

action

Determines when the attached stack of blocks will execute: pressed will run when a button is pressed, and released will run when a button is released.

Example

    when started
    take off to [500] [mm v] ▶
    forever
        move with controller
    end

    when controller button [5 v] [pressed v]
        [Take a picture when button 5 is pressed.]
        capture image on [forward v] camera

when controller axis is changed#

The when controller axis is changed hat block runs the attached stack of blocks when the specified axis is being changed.

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

A VEX AIR Drone Controller with joystick axes highlighted. Axis 1 and 2 are around the left joystick, and Axis 3 and 4 are around the right.

Parameters

Description

axis

The axis to monitor for changes:

  • 1 — The left joystick vertical axis.
  • 2 — The left joystick horizontal axis.
  • 3 — The right joystick horizontal axis.
  • 4 — The right joystick vertical axis.

Example

    when started
    [Move forward when the left joystick moves.]
    take off to [500] [mm v] ▶

    when controller axis [1 v] is changed
    move [forward v] for (200) [mm v] ▶