04-04 PWMOutput
From Manuals
(Difference between revisions)
| Line 1: | Line 1: | ||
The PWMOutput example sets PWM source to a fixed frequency and duty cycle. | The PWMOutput example sets PWM source to a fixed frequency and duty cycle. | ||
| + | |||
| + | /*Sets PWM source to fixed frequency and duty cycle. Observe output on oscilloscope. | ||
| + | */ | ||
| + | #include "mbed.h" | ||
| + | PwmOut pwm(PWM1); //create a PWM output called pwm on pin PWM1 | ||
| + | |||
| + | int main() | ||
| + | { | ||
| + | pwm.period(0.010); // set PWM period to 10 ms | ||
| + | pwm=0.5; // set duty cycle to 50% | ||
| + | } | ||
[[Image:BAM210_04_04.png|center|]] | [[Image:BAM210_04_04.png|center|]] | ||
Revision as of 15:03, 14 August 2014
The PWMOutput example sets PWM source to a fixed frequency and duty cycle.
/*Sets PWM source to fixed frequency and duty cycle. Observe output on oscilloscope.
*/
#include "mbed.h"
PwmOut pwm(PWM1); //create a PWM output called pwm on pin PWM1
int main()
{
pwm.period(0.010); // set PWM period to 10 ms
pwm=0.5; // set duty cycle to 50%
}

