NUCLEO-F042K6 Simple demo blinking LED using PWM
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:b2a1f2577916
- Child:
- 1:458a648ecbde
diff -r 000000000000 -r b2a1f2577916 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 31 20:17:00 2018 +0000 @@ -0,0 +1,13 @@ +#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); + } +}