pir plugin

This commit is contained in:
2018-12-03 15:34:27 +01:00
parent 65a43fb667
commit d906286eda
5 changed files with 108 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include "PirInputPlugin.h"
void PirInputPlugin::checkInput()
{
val = digitalRead(config.pin); // read input value
if (val == HIGH)
{ // check if the input is HIGH
if (pirState == LOW)
{
// we have just turned on
publish(config.topic, "1");
// We only want to print on the output change, not state
pirState = HIGH;
}
}
else
{
if (pirState == HIGH)
{
// we have just turned of
publish(config.topic, "0");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}