salida pwm#

Inicializando la clase pwm_out#

Una salida PWM se crea utilizando el siguiente constructor:

The pwm_out constructor creates a pwm_out object in the specified Three Wire Port:

Parámetro

Descripción

port

El puerto de 3 cables que se utilizará para la salida Pwm, ya sea un puerto en el Cerebro o un Expandedor de 3 cables.

Primero se debe crear un Brain o un 3-Wire Expander antes de poder usarlos para crear un objeto con el constructor de clase pwm_out.

// Create the Brain.
brain Brain;
// Construct a Pwm Output "pwm" with the Pwm class.
pwm_out pwm = pwm_out(Brain.ThreeWirePort.A);

This pwm object will be used in all subsequent examples throughout this API documentation when referring to pwm_out class methods.

Métodos de clase#

state()#

The state(value, units) command sets the state of the PWM.

Parámetros

Descripción

valor

El nuevo valor a establecer para la salida PWM, de -100 a +100 por ciento.

unidades

The only valid unit for pwm output is percent.

Devoluciones: Ninguna.

// Set the PWM Output to 50%.
  pwm.state(50, percent);