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 block returns 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 is facing backward with its 8 orange buttons highlighted yellow.

Parameters

Description

button

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

Example

    when started :: hat events
    [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 block returns the position of the specified joystick axis as a percentage. This returns an integer from –100 to 100.

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

A VEX AIR Drone Controller is facing forward with the joystick axes bordered by red boxes.

Parameters

Description

axis

The axis to return 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 :: hat events
    [Climb when the left joystick is moved up.]
    take off to [500] [mm v] ▶
    forever
        if <(controller axis [1 v] position) [> v] [0]> then
            climb [up v]
        else
            hover
    end

controller is connected?#

The controller is connected? block returns if the controller is connected to the drone. This block returns a Boolean value:

  • 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 :: hat events
    [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 is connected? block returns the battery level of the controller as a percentage.

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

Parameters

Description

This block has no parameters.

Example

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

when controller button#

The when controller button block activates 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] :: hat events

A VEX AIR Drone Controller is facing backward with its 8 orange buttons highlighted yellow.

Parameters

Description

button

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

button status

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

  • pressed
  • released

Example

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

    when controller button [5 v] [pressed v] :: hat events
        [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 block activates 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 :: hat events

A VEX AIR Drone Controller is facing forward with the joystick axes bordered by red boxes.

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 :: hat events
    [Move forward when the left joystick moves.]
    take off to [500] [mm v] ▶

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