mirror of
https://gitlab.com/wirelos/sprocket-plugin-gpio.git
synced 2025-12-14 13:26:48 +01:00
31 lines
716 B
C++
31 lines
716 B
C++
#include "PirInputPlugin.h"
|
|
|
|
void PirInputPlugin::checkInput()
|
|
{
|
|
|
|
if(startupDelay > millis()){
|
|
return;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|