Brain#

Introduction#

The VEX IQ (2nd Gen) Brain Sensing category offers methods for interacting with the Brain’s buttons and connected battery.

Below is a list of all available methods:

Actions – Interact with the VEX IQ (2nd Gen) Buttons.

  • pressed – Calls a function when the specified button is pressed.

  • released – Calls a function when the specified button is released.

Getters – Return data from the buttons and battery.

  • capacity – Returns the remaining battery capacity as a percentage.

  • pressing – Returns whether the specified button is being pressed.

  • voltage – Returns the battery voltage in volts.

  • current – Returns the battery current in amps.

Constructors – Manually initialize the Brain.

  • brain – Create a Brain.

Actions#

pressed#

pressed registers a function to be called when a specific button on the Brain is pressed. This method must be called on a specific button object, such as buttonCheck – (see full list of button objects below).

Usage:
One of the three available button objects can be used with this method, as shown below:

Button

Command

buttonCheck

Brain.buttonCheck.pressed(callback); — The Check button

buttonLeft

Brain.buttonLeft.pressed(callback); — The Left button

buttonRight

Brain.buttonRight.pressed(callback); — The Right button

Parameters

Description

callback

A function that is previously defined to execute when the specified button is being pressed.

// Example coming soon

released#

released registers a function to be called when a specific button on the Brain is released. This method must be called on a specific button object, such as buttonCheck – (see full list of button objects below).

Usage:
One of the three available button objects can be used with this method, as shown below:

Button

Command

buttonCheck

Brain.buttonCheck.released(callback); — The Check button

buttonLeft

Brain.buttonLeft.released(callback); — The Left button

buttonRight

Brain.buttonRight.released(callback); — The Right button

Parameters

Description

callback

A function that is previously defined to execute when the specified button is being pressed.

// Example coming soon

Getters#

capacity#

capacity returns the remaining battery capacity of the Brain as a percentage.

Usage:
Brain.Battery.capacity(units)

Parameters

Description

units

The unit that represents the capacity:

  • percent
// Example coming soon

pressing#

pressing returns a Boolean indicating whether a specific button on the Brain is currently being pressed. This method must be called on a specific button object, such as buttonCheck (see full list of button objects below).

  • 1 - The specified button is being pressed.

  • 0 - The specified button is not being pressed.

Usage:
One of three available button objects can be used with this method, as shown below:

Button

Command

buttonCheck

Brain.buttonCheck.pressing() — The Check button

buttonLeft

Brain.buttonLeft.pressing() — The Left button

buttonRight

Brain.buttonRight.pressing() — The Right button

Parameters

Description

This method has no parameters.

// Example coming soon

voltage#

voltage returns the Brain’s battery voltage in volts.

Usage:
Brain.Battery.voltage()

Parameters

Description

This method has no parameters.

// Example coming soon

current#

current returns the Brain’s battery current in amps.

Usage:
Brain.Battery.current()

Parameters

Description

This method has no parameters.

// Example coming soon

Constructors#

brain#

brain creates an object of the brain Class.

Usage:
brain Brain;

Parameter

Description

This constructor has no parameters.

// Example coming soon