setPeriod()
Description
Setup watch dog timer for specific time intervals.
Syntax
TimerWDT.setPeriod(time)
Parameter
time
:time interval,the unit is microsecond (μs)
Return
None
Example
Set up watch dog timer to interrupt mode, turn the LED on and off every 200ms:
#include <TimerWDT.h> void setup() { pinMode(13, OUTPUT); TimerWDT.initialize(); TimerWDT.setPeriod(200000); // time interval set up to 200ms TimerWDT.attachInterrupt( timerIsr ); // ISR, excute every 200ms } void loop() {} // ISR void timerIsr() { // turn on and off 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.