cerebro#
Inicializando la clase del cerebro#
El cerebro se crea utilizando el siguiente constructor:
The brain constructor creates a brain object.
// 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- Provides information about the EXP Brain’s battery, including capacity, voltage, and current.Button- Allows you to detect button presses and assign functions to button events on the EXP Brain.Timer- Provides functionality to measure elapsed time and assign functions to time-based events on the EXP Brain.Screen- Enables you to display text and draw images on the EXP Brain’s screen.SDcard- Provides access to files stored on the EXP Brain’s SD card.ThreeWirePort- Provides access to 3-Wire Sensors connected to the EXP Brain’s 3-Wire Ports. Each port is identified by a letter (A through H) and can be accessed using the formatBrian.ThreeWirePort.X, whereXis the port letter. For example,Brian.ThreeWirePort.Arefers to the Sensor connected to port A.
Atributos
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 |
|---|---|
|
A valid |
Devoluciones: Ninguna.
// Play a sound of type tada.
Brain.playSound(tada);
playTone()#
The playTone(tone, volume, duration) method plays a sound on the Brain.
Parámetros |
Descripción |
|---|---|
|
El tono a tocar. |
|
El volumen para reproducir el tono está en el rango 0 - 100. |
|
El tiempo que se necesita para reproducir el tono en milisegundos. |
Devoluciones: Ninguna.
// Play a tone on the Brain.
Brain.playTone(2, 50, 1000);
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 |
|---|---|
|
La octava a utilizar. |
|
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 |
|---|---|
|
La octava a utilizar. |
|
La nota a tocar. |
|
La duración en milisegundos para reproducir la nota. |
// Play a note on the Brain.
Brain.playNote(1, 4, 200);
reproducirArchivo()#
The playFile(filename, volume) method plays a sound file in .wav format on the Brain.
Parámetros |
Descripción |
|---|---|
|
El archivo de sonido a reproducir. |
|
El volumen del sonido en el rango 0 - 100. |
Devoluciones: Ninguna.
// Play the sound file titled "myfile.wav" on the Brain.
Brain.playFile('myfile.wav', 50);
sonido desactivado()#
The soundOff() method stops any sound that is playing.
Devoluciones: Ninguna.