Botón#

El cerebro IQ (1.ª generación) tiene acceso a tres objetos para sus tres botones:

  • botónCheck

  • botón Arriba

  • botón Abajo

apretado()#

El método pressed(callback) registra una función que se llamará cuando se presione un botón.

Parámetros

Descripción

llamar de vuelta

Una función que se llamará cuando se presione el botón.

Devoluciones: Ninguna.

// 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);
}

liberado()#

El método released(callback) registra una función que se llamará cuando se suelte un botón.

Parámetros

Descripción

llamar de vuelta

Una función que se llamará cuando se suelte el botón.

Devoluciones: Ninguna.

// 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);
}

prensado()#

El método pressing() devuelve si un botón está siendo presionado actualmente.

Devuelve: true si se está presionando el botón. false si no lo está.