Avoid accidentally turning on relay

Hello everyone, I am creating a project in which I activate 2 relay to turn on two water pumps, the question is: I need that to activate the relay the button in the application has to be pressed for 3 seconds, it is to prevent someone accidentally turn it off or turn it on with a touch, could someone tell me how to implement this function? Thank you.

HI, this might work . . .

  1. Check the state of the button (pressed or not-pressed)
  2. Start a three second timer
  3. When the timer finishes check the state of the button again
  4. If the button is still pressed after three seconds then activate the relay

Remember, don’t use delay() for your timer, Blynk doesn’t like delay(), use millis()

Good luck


A long discussion on the subject, along with some potential solutions, in this topic…


Gracias a ambos, fue de mucha ayuda. @Bill_Donnelly @PeteKnight