electroimán#
Inicializando la clase de electroimán#
Un objeto electroimán se crea utilizando el siguiente constructor:
The electromagnet constructor creates an electromagnet object in the specified Port:
Parámetro |
Descripción |
|---|---|
|
A valid |
// Construct an Electromagnet "magnet" with the
// electromagnet class.
electromagnet magnet = electromagnet(PORT1);
This magnet object will be used in all subsequent examples throughout this API documentation when referring to Electromagnet class methods.
Métodos de clase#
setPower()#
The setPower(power) method sets the power level of the electromagnet used to pickup and drop.
Parámetros |
Descripción |
|---|---|
|
El nivel de potencia se puede establecer en el rango 0 – 100. |
Devoluciones: Ninguna.
// Set the default power to 80%.
magnet.setPower(80);
pickup()#
Este método se llama de las siguientes maneras:
The pickup() method activates the electromagnet to pickup an object for the default duration and at the default power specified by the setPower() method.
// Set the magnet to pickup.
magnet.pickup();
The pickup(time, units) method activates the electromagnet to pickup an object for a specified duration and at the default power specified by the setPower() method.
Parámetros |
Descripción |
|---|---|
|
La duración para activar el electroimán. |
|
A valid |
// Set the magnet to pickup for 10 seconds.
magnet.pickup(10, seconds);
The pickup(time, units, power) method activates the electromagnet to pick up an object for a specified duration at a specified power.
Parámetros |
Descripción |
|---|---|
|
La duración para activar el electroimán. |
|
A valid |
|
El nivel de potencia a establecer. |
// Set the magnet to pickup for 10 seconds at 90% power.
magnet.pickup(10, seconds, 90);
Devoluciones: Ninguna.
drop()#
Este método se llama de las siguientes maneras:
The drop() method activates the electromagnet to pickup an object for the default duration and at the default power specified by the setPower() method.
Devoluciones: Ninguna.
// Set the magnet to drop.
magnet.drop();
The drop(time, units) method deactivates the electromagnet to drop an object for a specified duration and at the default power specified by the setPower() method.
Parámetros |
Descripción |
|---|---|
|
La duración para desactivar el electroimán. |
|
A valid |
Devoluciones: Ninguna.
// Set the magnet to drop for 10 seconds.
magnet.drop(10, seconds);
The drop(time, units, power) method deactivates the electromagnet to drop an object for a specified duration at a specified power.
Parámetros |
Descripción |
|---|---|
|
La duración para desactivar el electroimán. |
|
A valid |
|
El nivel de potencia a establecer. |
Devoluciones: Ninguna.
// Set the magnet to drop for 10 seconds at 90 percent power.
magnet.drop(10, seconds, 90);
temperature()#
The temperature(units) method returns the temperature of the electromagnet.
Parámetros |
Descripción |
|---|---|
|
A valid |
Devuelve: Un doble que representa la temperatura del electroimán.
timestamp()#
The timestamp() method requests the timestamp of the last received status packet from the Electromagnet.
Devuelve: Marca de tiempo del último paquete de estado como un entero de 32 bits sin signo en milisegundos.
installed()#
The installed() method returns if the electromagnet is connected.
Returns: true if the electromagnet is installed. false if it is not.