attachInterrupt()
説明
ユーザー ISR をマウントして、同時にウォッチドッグタイマーを起動する。(*この関数はタイマー中断モードでしか使えない。)
プログラミング言語
TimerWDT.attachInterrupt(isr)
TimerWDT.attachInterrupt(isr, time)
パラメーター
isr
:実行の関数名。
time
:時間サイクル設定(関数を選べる、不必要)、単位は µs。
フィードバック
なし
例
ウォッチドッグタイマーをタイマー中断モードに設定する。100ms ごとに LED を点滅させる。
#include <TimerWDT.h> void setup() { pinMode(13, OUTPUT); TimerWDT.initialize(100000); // 100ms ごとに設定する TimerWDT.attachInterrupt( timerIsr ); // ユーザー ISR をマウントして,100ms ごとに実行する } void loop() {} // ユーザー ISR void timerIsr() { // LED を点滅させる digitalWrite( 13, digitalRead( 13 ) ^ 1 ); }
See also
- detachInterrupt()
The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.