Tomasz Rodziewicz
/
Nucleo_LED_PWM_Pulsing
Program pulses the board LED from 0% to 100% and back using soft PWM. Tested on Nucleo F030R8.
Revision 0:ee3ee6288b15, committed 2014-05-27
- Comitter:
- TRodziewicz
- Date:
- Tue May 27 16:54:20 2014 +0000
- Commit message:
- Program pulses the board LED from 0% to 100% and back using soft PWM.; ; Tested on Nucleo F030R8.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 27 16:54:20 2014 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +#define PWM_STEPS 100 +#define PWM_SPEED 50 +#define LED_ON 1 +#define LED_OFF 0 + +DigitalOut myled(LED1); + +void blink_led(int from, int to) +{ + for (int i = 0; i < PWM_STEPS; i++) { + myled = from; + wait_us(i * PWM_SPEED); + + myled = to; + wait_us((PWM_STEPS - i) * PWM_SPEED); + } +} + +int main() { + while (1) { + blink_led(LED_ON, LED_OFF); + blink_led(LED_OFF, LED_ON); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue May 27 16:54:20 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877 \ No newline at end of file