setPeriod()
描述
设定看门狗计时器的时间週期。
语法
TimerWDT.setPeriod(time)
参数
time
:时间週期,单位为微秒(us)。
回传
无回传值
范例
设定看门狗计时器为计时中断模式, 每隔 200ms 点亮和熄灭 LED:
#include <TimerWDT.h> void setup() { pinMode(13, OUTPUT); TimerWDT.initialize(); TimerWDT.setPeriod(200000); // 时间週期设定为 200ms TimerWDT.attachInterrupt( timerIsr ); // 挂载使用者 ISR, 每隔 200ms 执行一次 } void loop() {} // 使用者 ISR void timerIsr() { // 交替点亮和熄灭 LED 灯 digitalWrite( 13, digitalRead( 13 ) ^ 1 ); }
See also
- initialize()
- attachInterrupt()
- 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.