Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.
Class | Supervisor |
||
---|---|---|---|
Name | addRule() |
||
Examples | #include <Supervisor.h> int x = 0; /* Define the rule itself */ SupervisedRule<int> ledOnFirstTenSeconds(x,checkFirstTen,handleAfterTen); /* Define the rule helpers */ //this function will return true the first ten seconds //when it return false (aka the rule failed) the handler will be called boolean checkFirstTen(int x) { if (millis()<10000) { return true; } return false; } //the first ten seconds have passed //turn off the LED and remove the rule void handleAfterTen(int &x) { digitalWrite(WLED, LOW); Supervisor.removeRule(ledOnFirstTenSeconds); } void setup() { Supervisor.addRule(ledOnFirstTenSeconds); pinMode(WLED,OUTPUT); digitalWrite(WLED, HIGH); } void loop() { Supervisor.checkRules(); } |
||
Description | Add a rule for this Supervisor to supervise. | ||
Syntax | addRule(rule) |
||
Parameters |
|
||
Returns | None | ||
Usage | Application |