cerebro#

Inicializando la clase del cerebro#

El cerebro se crea utilizando el siguiente constructor:

The brain constructor uses no parameters.

// Create a new object "Brain" with the brain class.
brain Brain;

This Brain object will be used in all subsequent examples throughout this API documentation when referring to brain class methods and attributes.

La clase cerebro viene con seis atributos predefinidos:

  • Battery - Proporciona información sobre la batería del cerebro IQ (1.ª generación), incluida la capacidad, el voltaje y la corriente.

  • Button - Le permite detectar pulsaciones de botones y asignar funciones a eventos de botones en el cerebro IQ (1.ª generación).

  • Timer - Proporciona funcionalidad para medir el tiempo transcurrido y asignar funciones a eventos basados en el tiempo en el cerebro IQ (1.ª generación).

  • Screen - Le permite mostrar texto y dibujar imágenes en la pantalla del cerebro IQ (1.ª generación).

Métodos de clase#

Además de sus atributos, la clase Brain proporciona varios métodos que se pueden utilizar directamente.

reproducirSonido()#

The playSound(sound) method plays a sound on the Brain.

Parámetros

Descripción

sonido

Un soundType válido.

Devoluciones: Ninguna.

// Play a sound of type TADA.
Brain.playSound(tada);

playNote()#

Este método se puede llamar de las siguientes maneras:

The playNote(octave, note) method plays a note in the given octave on the Brain.

Parámetros

Descripción

octava

La octava a utilizar.

nota

La nota a tocar.

// Play a note on the Brain.
Brain.playNote(1, 4);

The playNote(octave, note, duration) method plays a note in the given octave on the Brain and waits for the given time before returning.

Parámetros

Descripción

octava

La octava a utilizar.

nota

La nota a tocar.

duración

La duración en milisegundos para reproducir la nota.

// Play a note on the Brain.
Brain.playNote(1, 4, 200);

sonido desactivado()#

The Brain.soundOff() method stops any sound that is playing.

Devoluciones: Ninguna.