pwm_out#
初始化 pwm_out 类#
PWM 输出是通过以下构造函数创建的:
The pwm_out constructor creates a pwm_out object in the specified Three Wire Port:
范围 |
描述 |
|---|---|
|
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_out Class constructor.
// 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.
类方法#
state()#
The state(value, units) command sets the state of the PWM.
参数 |
描述 |
|---|---|
|
PWM 输出的新设置值,范围从 -100% 到 +100%。 |
|
The only valid unit for pwm output is |
**返回值:**无。
// Set the PWM Output to 50%.
pwm.state(50, percent);