안녕하세요 @realmankwon입니다. 아두이노에서 setTimeout 을 쓸 일이 생겼습니다. 다른 언어들은 기본으로 제공을 하지만 아두이노의 경우에는 SimpleTimer 라이브러를 추가 시켜줘야했습니다. 일단 SimpleTimer 를 찾아서 다운로드 받고 라이브러리를 추가시켜주었습니다. - https://playground.arduino.cc/Code/SimpleTimer/ - 소스 경로 : https://github.com/schinken/SimpleTimer 소스 파일을 zip으로 받은 후에 .zip 라이브러리 추가를 해주면 외부 라이브러리가 추가가 됩니다. ![](https://cdn.steemitimages.com/DQmdYbF4s1NSnbiyavXSd9dYK8XxqWkKqWBprK8E6DcDHs5/image.png) ### 1 . 라이브러리 선언 ~~~ #include <SimpleTimer.h> ~~~ ### 2 . timer 변수 선언 ~~~ SimpleTimer timer; int timerId; ~~~ ### 3 . setTimeout 호출 - setTimeout 호출시 return 값을 저장해 둡니다. - return 값은 해당 timer 스레드의 ID 이며 필요시 스레드를 중단시키거나 재실행하는데 사용됩니다. ~~~ timerId = timer.setTimeout(3000, [function]); ~~~ ### 4 . timer 중단 및 재실행 ~~~ if(timer.isEnabled(timerId)) timer.disable(timerId); ~~~ ### 5 . timer 실행 - 가장 중요한 것은 loop() 함수에서 timer를 실행시켜주어야 하는 것입니다. - 아래의 실행 부분이 없으면 setTimeout은 실행되지 않습니다. ~~~ void loop(){ ..... ..... timer.run(); } ~~~ 언어를 넘나들다보니 더 많은 것을 알아간다기 보다 더 많은 혼란이 가중되는 느낌이네요. ㅎㅎ 이렇게 정리를 해놔야 나중에 도움이 될 것 같아서 요즘은 항상 정리를 하고 있습니다.
author | realmankwon |
---|---|
permlink | realmankwon-posting-2020-10-06-16-36 |
category | hive-132971 |
json_metadata | {"tags":["sct","sct-kr","sct-freeboard","s","union","zzan","dev","mini","kr","sago"],"app":"steemcoinpan/0.1"} |
created | 2020-10-06 07:38:39 |
last_update | 2020-10-06 07:38:39 |
depth | 0 |
children | 0 |
last_payout | 2020-10-13 07:38:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.348 HBD |
curator_payout_value | 0.265 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,115 |
author_reputation | 256,638,399,773,710 |
root_title | "[개발] Arduino 에서 setTimeout 실행" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 99,986,953 |
net_rshares | 3,609,522,500,001 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
livingfree | 0 | 343,897,780,530 | 5% | ||
netaterra | 0 | 509,236,723,736 | 26% | ||
created | 0 | 834,776,658,310 | 5% | ||
fatman | 0 | 16,852,957,954 | 8.55% | ||
investegg | 0 | 16,955,042,360 | 0.78% | ||
dmwh | 0 | 2,807,791,659 | 2.5% | ||
harryji | 0 | 32,563,343,359 | 70% | ||
calist | 0 | 145,059,518 | 100% | ||
llfarms | 0 | 1,014,648,257 | 5% | ||
idkpdx | 0 | 184,753,258 | 2.5% | ||
payroll | 0 | 71,887,498,069 | 2% | ||
pladozero | 0 | 67,153,334,679 | 10% | ||
nateaguila | 0 | 298,850,803,563 | 8% | ||
kibumh | 0 | 990,737,033 | 100% | ||
luminaryhmo | 0 | 3,345,253,289 | 100% | ||
laissez-faire | 0 | 105,811,574 | 100% | ||
xxxxxxxxxx | 0 | 1,353,117,586,454 | 5% | ||
justineh | 0 | 11,445,455,050 | 5% | ||
travelwritemoney | 0 | 897,801,155 | 5% | ||
freedomteam2019 | 0 | 992,460,935 | 20% | ||
therealyme | 0 | 2,079,071,327 | 26% | ||
innerhive | 0 | 34,545,814,566 | 5% | ||
hiveyoda | 0 | 5,676,113,366 | 5% |