2016-06-29 15:00:22 +00:00
|
|
|
#include <SpejsNode.h>
|
2015-12-26 23:29:30 +00:00
|
|
|
|
2016-06-29 15:00:22 +00:00
|
|
|
SpejsNode node("switch");
|
2015-12-26 23:29:30 +00:00
|
|
|
|
2016-06-29 15:00:22 +00:00
|
|
|
void init() {
|
|
|
|
node.init();
|
2016-09-10 23:46:42 +00:00
|
|
|
node.registerInput("relay", *[](String key, String value) {
|
2016-06-29 15:00:22 +00:00
|
|
|
Serial.println("handler");
|
|
|
|
digitalWrite(5, value == "1" ? HIGH : LOW);
|
2015-12-26 23:29:30 +00:00
|
|
|
});
|
2016-06-29 15:00:22 +00:00
|
|
|
pinMode(5, OUTPUT);
|
|
|
|
digitalWrite(5, LOW);
|
2015-12-26 23:29:30 +00:00
|
|
|
attachInterrupt(BTN_PIN, *[] {
|
2016-06-29 15:00:22 +00:00
|
|
|
node.notify("btn", String(digitalRead(BTN_PIN)));
|
|
|
|
}, CHANGE);
|
|
|
|
//node.registerInputGPIO("btn", BTN_PIN);
|
|
|
|
//node.registerOutputGPIO("led", LED_PIN);
|
2015-12-26 23:29:30 +00:00
|
|
|
}
|