![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
而我
main.cpp@0:59ed30c4ca5a, 2017-01-13 (annotated)
- Committer:
- wbqaston
- Date:
- Fri Jan 13 03:14:21 2017 +0000
- Revision:
- 0:59ed30c4ca5a
????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wbqaston | 0:59ed30c4ca5a | 1 | #include "mbed.h" |
wbqaston | 0:59ed30c4ca5a | 2 | |
wbqaston | 0:59ed30c4ca5a | 3 | Ticker toggle_led_ticker; |
wbqaston | 0:59ed30c4ca5a | 4 | |
wbqaston | 0:59ed30c4ca5a | 5 | DigitalOut led1(LED1); |
wbqaston | 0:59ed30c4ca5a | 6 | |
wbqaston | 0:59ed30c4ca5a | 7 | void toggle_led() { |
wbqaston | 0:59ed30c4ca5a | 8 | led1 = !led1; |
wbqaston | 0:59ed30c4ca5a | 9 | } |
wbqaston | 0:59ed30c4ca5a | 10 | |
wbqaston | 0:59ed30c4ca5a | 11 | int main() { |
wbqaston | 0:59ed30c4ca5a | 12 | // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) |
wbqaston | 0:59ed30c4ca5a | 13 | toggle_led_ticker.attach(&toggle_led, 0.1); |
wbqaston | 0:59ed30c4ca5a | 14 | while (true) { |
wbqaston | 0:59ed30c4ca5a | 15 | // Do other things... |
wbqaston | 0:59ed30c4ca5a | 16 | } |
wbqaston | 0:59ed30c4ca5a | 17 | } |