A pulse-width modulation digital output. More...
#include <PwmOut.h>
Public Member Functions | |
PwmOut (PinName pin) | |
Create a PwmOut connected to the specified pin. More... | |
void | write (float value) |
Set the output duty-cycle, specified as a percentage (float) More... | |
float | read () |
Return the current output duty-cycle setting, measured as a percentage (float) More... | |
void | period (float seconds) |
Set the PWM period, specified in seconds (float), keeping the duty cycle the same. More... | |
void | period_ms (int ms) |
Set the PWM period, specified in milliseconds (int), keeping the duty cycle the same. More... | |
void | period_us (int us) |
Set the PWM period, specified in microseconds (int), keeping the duty cycle the same. More... | |
void | pulsewidth (float seconds) |
Set the PWM pulsewidth, specified in seconds (float), keeping the period the same. More... | |
void | pulsewidth_ms (int ms) |
Set the PWM pulsewidth, specified in milliseconds (int), keeping the period the same. More... | |
void | pulsewidth_us (int us) |
Set the PWM pulsewidth, specified in microseconds (int), keeping the period the same. More... | |
PwmOut & | operator= (float value) |
A operator shorthand for write() More... | |
PwmOut & | operator= (PwmOut &rhs) |
A operator shorthand for write() More... | |
operator float () | |
An operator shorthand for read() More... | |
A pulse-width modulation digital output.
Example
PwmOut | ( | PinName | pin | ) |
operator float | ( | ) |
PwmOut& operator= | ( | float | value | ) |
void period | ( | float | seconds | ) |
Set the PWM period, specified in seconds (float), keeping the duty cycle the same.
seconds | Change the period of a PWM signal in seconds (float) without modifying the duty cycle |
void period_ms | ( | int | ms | ) |
void period_us | ( | int | us | ) |
void pulsewidth | ( | float | seconds | ) |
void pulsewidth_ms | ( | int | ms | ) |
void pulsewidth_us | ( | int | us | ) |
float read | ( | void | ) |
Return the current output duty-cycle setting, measured as a percentage (float)
void write | ( | float | value | ) |
Set the output duty-cycle, specified as a percentage (float)
value | A floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f. |