PWM Out#
Introduction#
The pwm_out class is used to control PWM (Pulse Width Modulation) output on a VEX V5 3-Wire port. It allows devices to send variable-width pulse signals to compatible 3-Wire components.
Class Constructors#
pwm_out(
triport::port &port );
Class Destructor#
Destroys the pwm_out object and releases associated resources.
~pwm_out();
Parameters#
Parameter |
Type |
Description |
|---|---|---|
|
|
The 3-Wire Port the PWM output is connected to, written as |
Example#
// Create the pwm_out instance on 3-Wire Port A
pwm_out pwm = pwm_out(Brain.ThreeWirePort.A);
Member Functions#
The pwm_out class includes the following member functions:
state— Sets the state of the PWM output.
Before calling any pwm_out member functions, a pwm_out instance must be created, as shown below:
/* This constructor is required when using VS Code.
PWM configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create the pwm_out instance on 3-Wire Port A
pwm_out pwm = pwm_out(Brain.ThreeWirePort.A);
state#
Sets the state of the PWM output to a specified value.
Available Functionsvoid state(
int32_t value,
percentUnits units );
Parameter |
Type |
Description |
|---|---|---|
|
|
The new value to set for PWM output, from -100 to +100 percent. |
|
|
The unit used to represent the PWM value:
|
This function does not return a value.
NotesThe PWM output value ranges from -100 to +100 percent.
The only valid unit for PWM output is
percent.
// Set the PWM Output to 50%
pwm.state(50, percent);
// Set the PWM Output to -75%
pwm.state(-75, percent);