Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Nucleo_blink_led by
main.cpp
- Committer:
- vjwramasamy
- Date:
- 2015-05-05
- Revision:
- 4:4539efb716ad
- Parent:
- 3:fdab3990f086
- Child:
- 5:602760db0b2d
File content as of revision 4:4539efb716ad:
#include "mbed.h" InterruptIn mybutton(USER_BUTTON); DigitalOut myled(LED1); PwmOut mypwm(PWM_OUT); int i=250; void pressed() { switch (i) { case 250: { i=500; mypwm.period_ms(10); mypwm.pulsewidth_ms(2); } break; case 500: i=750; mypwm.period_ms(10); mypwm.pulsewidth_ms(3); break; case 750: i=1000; mypwm.period_ms(10); mypwm.pulsewidth_ms(4); break; case 1000: i=1250; mypwm.period_ms(10); mypwm.pulsewidth_ms(5); break; case 1250: i=1500; mypwm.period_ms(10); mypwm.pulsewidth_ms(6); break; case 1500: i=250; mypwm.period_ms(10); mypwm.pulsewidth_ms(1); break; default: i=250; mypwm.period_ms(10); mypwm.pulsewidth_ms(1); break; } } int main() { mybutton.fall(&pressed); while(1) { myled = 1; // LED is ON wait_ms(i); // in ms myled = 0; // LED is OFF wait_ms(i); // in ms } }