![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Robotics LAB LED
Dependencies: mbed
實驗二
使開發板上之LED以每秒一次的頻率閃爍
Hint
- 將Ticker頻率設為100 Hz (週期10ms)
- 以計數器方式計算一秒
Due Date:2018/03/16
Revision 0:9249cba27176, committed 2018-02-28
- Comitter:
- roger5641
- Date:
- Wed Feb 28 11:23:48 2018 +0000
- Commit message:
- Robotics LAB LED
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 |
diff -r 000000000000 -r 9249cba27176 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 28 11:23:48 2018 +0000 @@ -0,0 +1,39 @@ +/*LAB_LED*/ +#include "mbed.h" + +//LED1 = D13 = PA_5 (LED on Nucleo board) +DigitalOut led1(LED1); +Ticker timer1; + +//Function declaration +void init_IO(); +void timer1_interrupt(); +void init_TIMER(); + +int main() +{ + init_IO(); + init_TIMER(); + + while(1) + { + ; + } +} + +void timer1_interrupt() +{ + ///YOUR CODE HERE/// +} + +void init_IO() +{ + led1 = 0; +} + +void init_TIMER(void) +{ + ///Setup timer1/// + // the address of the function is to be attached (timer1_interrupt) and the interval (10000 micro-seconds) + timer1.attach_us(&timer1_interrupt, 10000.0);//10ms interrupt period (100 Hz) +}
diff -r 000000000000 -r 9249cba27176 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Feb 28 11:23:48 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/5571c4ff569f \ No newline at end of file