Controller#
Introduction#
The VEX IQ (2nd gen) Controller has buttons and two joysticks. Controller blocks can be used to check button presses, read joystick movement, enable or disable configured controller actions, or run blocks when controller events happen.
The IQ (2nd gen) Brain can connect to either an IQ (2nd gen) or IQ (1st gen) Controller. An IQ (1st gen) Controller must have a blue Smart Radio installed.
Configured controller actions are controller behaviors set in the Devices menu. Use the controller enable/disable block to temporarily enable or disable those configured actions during a project.
Below is a list of all blocks:
Booleans — Check controller button status.
controller button pressed? — Returns whether a selected controller button is being pressed.
Reporters — Read joystick position.
controller axis position — Returns the joystick position along a selected axis.
Actions — Enable or disable configured controller actions.
controller enable/disable — Enables or disables controller actions configured in the Devices menu.
Events — Run blocks when controller input changes.
when controller button — Runs the attached stack when a selected button is pressed or released.
when controller axis is changed — Runs the attached stack when a joystick’s position changes along the selected axis.
Booleans#
Reporters#
controller axis position#
The controller axis position reporter block returns the joystick position along a selected axis as a number from -100 to 100.
(Controller [A v] position)
Parameter |
Description |
|---|---|
axis |
The joystick axis to report:
|
Example
when started
[Turn depending on the position of the right joystick.]
forever
if <(Controller [C v] position) [math_less_than v] [0]> then
turn [left v]
else if <(Controller [C v] position) [math_greater_than v] [0]> then
turn [right v]
else
stop driving
end
end
Actions#
controller enable/disable#
The controller enable/disable stack block enables or disables controller actions configured in the Devices menu.
Controller [Disable v]
Parameter |
Description |
|---|---|
state |
The controller configured action state: Disable or Enable. |
Example
when started
[Disable controller configured actions until the drive movement is done.]
Controller [Disable v]
drive [forward v] for (6) [inches v] ▶
Controller [Enable v]
Events#
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.
when Controller axis [A v] is changed
Parameter |
Description |
|---|---|
axis |
The joystick axis to check:
|
Example
when Controller axis [C v] is changed
[Turn when the joystick's position changes along axis C.]
turn [right v] for (90) degrees ▶