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? — Checks if a specific button is currently being pressed.
controller axis position — Returns the position of the joystick along a specified axis.
controller is connected? — Returns whether or not the controller is connected to the drone.
controller battery level — Returns the controller’s battery level.
when controller button — Runs a stack of blocks when a button is pressed or released.
when controller axis is changed — Runs a stack of blocks when the joystick position changes.
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.
(controller axis [1 v] position)
Parameters |
Description |
---|---|
axis |
The axis to return the position of:
|
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.
<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.
(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 axis is changed#
The when controller axis is changed block activates the attached stack of blocks when the specified axis is being changed.
when controller axis [1 v] is changed :: hat events
Parameters |
Description |
---|---|
axis |
The axis to report the position of:
|
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] ▶