SEARCH
TOOLBOX
LANGUAGES
modified on 17 September 2014 at 14:37 ••• 39,747 views

04-04 PWMOutput

From Manuals

Revision as of 14:37, 17 September 2014 by Support (Talk | contribs)
Jump to: navigation, search

The PWMOutput example sets PWM source to a fixed frequency and duty cycle. The PWM output can be observed on D2 (J9 pin 3).

/*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%
}