on temporary protection after 10 seconds if the sensor has not arrived to the off position you must stop the pump and trigger an alarm at the same time if the sesore returns off the first of 10 seconds must always stop the pump but without alarm
I did so but I do not work the time of 10 seconds
Code: Select all
const byte sensorerabbocco = 49;
const byte pinrabbocco = 47;
boolean allarme_rabbocco = false;
unsigned long temporabbocco = 0;
tab setup
Code: Select all
pinMode(sensorerabbocco, INPUT_PULLUP);
pinMode(pinrabbocco, OUTPUT);
tab loop
Code: Select all
if (digitalRead (sensorerabbocco) == LOW)
{
if (allarme_rabbocco == false)
{
digitalWrite(pinrabbocco, HIGH);
if (millis() - temporabbocco > 10000)
{
digitalWrite(pinrabbocco, LOW);
allarme_rabbocco = true;
temporabbocco = millis();
}
}
}
else
{
digitalWrite(pinrabbocco, LOW);
temporabbocco = millis();
}