Button#

The EXP Brain has access to three objects for its three buttons:

  • buttonCheck

  • buttonLeft

  • buttonRight

pressed()#

The pressed(callback) method registers a function to be called when a button is pressed.

Parameters

Description

callback

A function that will be called when the button is pressed.

Returns: None.

// Create a new function buttonPressed().
void button_pressed() {
  Brain.Screen.print("button pressed");
}

int main() {
  // When the Brain's Left button is pressed, run the
  // button_pressed function.
  Brain.buttonLeft.pressed(buttonPressed);
}

released()#

The released(callback) method registers a function to be called when a button is released.

Parameters

Description

callback

A function that will be called when the button is released.

Returns: None.

// Create a new function buttonReleased().
void button_pressed() {
  Brain.Screen.print("button released");
}

int main() {
  // When the Brain's Left button is released, run the
  // button_pressed function.
  Brain.buttonLeft.released(buttonReleased);
}

pressing()#

The pressing() method returns whether a button is currently being pressed.

Returns: true if the button is being pressed. false if it is not.