Brain Sensing#

Introduction#

The Brain Sensing category includes blocks that detect input from the VEX IQ (2nd gen) Brain and report internal system values. These blocks allow your project to respond to button presses, monitor battery status, and determine the current screen cursor position when printing.

These blocks are often used in tandem with visual feedback tools such as the Screen or Console blocks, helping create interactive or responsive programs during runtime.

Below is a list of available blocks:

  • brain button pressed? – Returns a Boolean indicating whether a specific Brain button is currently pressed.

  • battery capacity – Returns the current battery level as a percentage.

  • when Brain button – Executes the attached stack of blocks when a Brain button is pressed or released.

brain button pressed?#

The brain button pressed? block returns if a specified Brain button is currently being pressed or not pressed. This block returns a Boolean value:

  • True - The specified button is being pressed.

  • False - The specified button is not being pressed

    <Brain [Left v] button pressed?>

Parameters

Description

button

The button to check for a press or release:

  • Left
  • Right
  • Check

Example

    when started :: hat events
    [Spin when a Brain button is pressed.]
    wait until <Brain [Right v] button pressed?>
    turn [right v] for (360) degrees ▶

battery capacity#

The battery capacity block returns the battery charge level as a percentage. This returns a number from 0 to 100.

    (battery capacity in %)

Parameters

Description

This block has no parameters.

Example

    when started :: hat events
    [Display the current battery capacity.]
    print (battery capacity in %) on screen ◀ and set cursor to next row

when Brain button#

The when Brain button block runs the attached stack of blocks when the selected Brain button is pressed or released.

When brain button event hat block#
    when Brain [left v] button [pressed v] :: hat events

Parameters

Description

buttons

Determines which button will trigger the event:

  • left
  • right
  • Check

action

Determines when the attached stack of blocks will execute:

  • pressed
  • released

Example

When the screen is pressed, the brain displays a text.#
    when Brain [left v] button [pressed v] :: hat events
        [Display a text when the left button is pressed.]
        print [Hello, IQ!] on screen ◀ and set cursor to next row