Hsing-Hung Lai
/
Nucleo_LED
homework_1
Revision 0:5e39cd6c5291, committed 2016-03-10
- Comitter:
- tim65132006
- Date:
- Thu Mar 10 14:05:44 2016 +0000
- Commit message:
- 03101005;
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 Thu Mar 10 14:05:44 2016 +0000 @@ -0,0 +1,44 @@ +/*LAB_LED*/ +#include "mbed.h" + +//LED1 = D13 = PA_5 (LED on Nucleo board) + +DigitalOut led1(LED1); +Ticker timer1; + +int a; + +void init_IO(void) +{ + a = 0; + led1 = 0; +} + +void timer1_interrupt(void) +{ + a = a+1; +} + +void init_TIMER(void) +{ + timer1.attach_us(&timer1_interrupt, 1000.0);//1ms interrupt period (1 KHz) +} + +int main() +{ + + init_IO(); + init_TIMER(); + + while(1) { + + if (a==500) { + led1 = 1; + } + + if(a==1000) { + led1 = 0; + a = 0; + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Mar 10 14:05:44 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb \ No newline at end of file