pwm_out#
Initializing the pwm_out Class#
A PWM Output is created by using the following constructor:
The pwm_out
constructor creates a pwm_out object in the specified Three Wire Port:
Parameter |
Description |
---|---|
|
The 3-Wire Port to use for the Pwm Output, whether it’s a port on the Brain, or a 3-Wire Expander. |
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.
Class Methods#
state()#
The state(value, units)
command sets the state of the PWM.
Parameters |
Description |
---|---|
value |
The new value to set for PWM output, from -100 to +100 percent. |
units |
The only valid unit for pwm output is |
Returns: None.
// Set the PWM Output to 50%.
pwm.state(50, percent);