NUCLEO-F042K6 Simple demo blinking LED using PWM

Dependencies:   mbed

Committer:
vodsejak
Date:
Wed Jan 31 20:17:00 2018 +0000
Revision:
0:b2a1f2577916
Child:
1:458a648ecbde
v1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vodsejak 0:b2a1f2577916 1 #include "mbed.h"
vodsejak 0:b2a1f2577916 2
vodsejak 0:b2a1f2577916 3 PwmOut PWM(PA_8);
vodsejak 0:b2a1f2577916 4
vodsejak 0:b2a1f2577916 5 int main() {
vodsejak 0:b2a1f2577916 6
vodsejak 0:b2a1f2577916 7 PWM.period_ms(500); // period of PWM - f=1/T -> f=1/0.5=2 Hz
vodsejak 0:b2a1f2577916 8 PWM.pulsewidth_ms(250); // duration of active pulse - sets duty cycle - duty cycle = pulsewidth/period
vodsejak 0:b2a1f2577916 9
vodsejak 0:b2a1f2577916 10 while(1) {
vodsejak 0:b2a1f2577916 11 wait_ms(1000);
vodsejak 0:b2a1f2577916 12 }
vodsejak 0:b2a1f2577916 13 }