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.
Dependencies: mbed
Fork of Ticker_3 by
main.cpp@4:af3ab097055c, 2017-10-15 (annotated)
- Committer:
- ajy912
- Date:
- Sun Oct 15 12:02:45 2017 +0000
- Revision:
- 4:af3ab097055c
- Parent:
- 3:9be917b0d07a
Ticker_3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ajy912 | 2:e94dce9a7464 | 1 | /* Ticker : 함수를 쓰는 시간에 시작하여 원하는 시간이 지나면 특정 함수를 호출하고 |
ajy912 | 2:e94dce9a7464 | 2 | 다시 초기화 하여 원하는 시간이 되면 호출하는 것을 반복한다.*/ |
ajy912 | 2:e94dce9a7464 | 3 | |
ajy912 | 4:af3ab097055c | 4 | /*결과: red_LED 5초동안 깜빡이다가 green_LED 5초동안 on유 반복*/ |
ajy912 | 2:e94dce9a7464 | 5 | |
ajy912 | 0:0ba4641adab9 | 6 | |
ajy912 | 0:0ba4641adab9 | 7 | #include "mbed.h" |
ajy912 | 0:0ba4641adab9 | 8 | |
ajy912 | 2:e94dce9a7464 | 9 | Ticker timer; |
ajy912 | 4:af3ab097055c | 10 | DigitalOut ledg(LED2); |
ajy912 | 4:af3ab097055c | 11 | DigitalOut ledr(LED1); |
ajy912 | 1:3b84da6d133f | 12 | |
ajy912 | 2:e94dce9a7464 | 13 | void attime() { |
ajy912 | 4:af3ab097055c | 14 | ledg =! ledg; |
ajy912 | 0:0ba4641adab9 | 15 | } |
ajy912 | 0:0ba4641adab9 | 16 | |
ajy912 | 0:0ba4641adab9 | 17 | int main() { |
ajy912 | 4:af3ab097055c | 18 | ledg=1; |
ajy912 | 2:e94dce9a7464 | 19 | timer.attach(&attime,5); //메인 함수는 계속 실행이 되면서 5초 뒤에 attime을 호출한다. 반복적으로 |
ajy912 | 4:af3ab097055c | 20 | |
ajy912 | 0:0ba4641adab9 | 21 | while(1) { |
ajy912 | 1:3b84da6d133f | 22 | |
ajy912 | 4:af3ab097055c | 23 | ledr =! ledr; |
ajy912 | 4:af3ab097055c | 24 | wait(0.2); |
ajy912 | 1:3b84da6d133f | 25 | |
ajy912 | 2:e94dce9a7464 | 26 | } |
ajy912 | 2:e94dce9a7464 | 27 | |
ajy912 | 0:0ba4641adab9 | 28 | } |