Button#
The IQ (1st gen) Brain has access to three objects for its three buttons:
buttonCheckbuttonUpbuttonDown
pressed()#
The pressed(callback) method registers a function to be called when a button is pressed.
Parameters  | 
Description  | 
|---|---|
  | 
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 Up button is pressed, run the
  // button_pressed function.
  Brain.buttonUp.pressed(buttonPressed);
}
released()#
The released(callback) method registers a function to be called when a button is released.
Parameters  | 
Description  | 
|---|---|
  | 
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 Up button is released, run the
  // button_pressed function.
  Brain.buttonUp.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.