NUCLEO-F042K6 Simple demo using PWM to controll LED brightness

Dependencies:   mbed

main.cpp

Committer:
vodsejak
Date:
2018-01-31
Revision:
0:b2a1f2577916
Child:
1:458a648ecbde

File content as of revision 0:b2a1f2577916:

#include "mbed.h"

PwmOut PWM(PA_8);

int main() {
    
    PWM.period_ms(500); // period of PWM - f=1/T -> f=1/0.5=2 Hz
    PWM.pulsewidth_ms(250); // duration of active pulse - sets duty cycle - duty cycle = pulsewidth/period
    
    while(1) {
        wait_ms(1000);
    }
}