Pwm#
Inicializando la clase Pwm#
Una salida Pwm se crea utilizando el siguiente constructor:
Pwm(port)
Este constructor utiliza un parámetro:
Parámetro |
Descripción |
|---|---|
|
The 3-Wire Port to use for the Pwm Output, whether it’s a port on the |
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the Pwm Class constructor.
# Create the Brain.
brain = Brain()
# Construct a Pwm Output "pwm" with the Pwm class.
pwm = Pwm(brain.three_wire_port.a)
This pwm object will be used in all subsequent examples throughout this API documentation when referring to Pwm class methods.
Métodos de clase#
state()#
The state(value, units) method sets the state of the PWM.
Parámetros |
Descripción |
|---|---|
|
El nuevo valor a establecer para la salida PWM, de -100 a +100 por ciento. |
|
Optional. The only valid unit for pwm output is |
Devoluciones: Ninguna.
# Set PWM output to 50%.
pwm.state(50)