Button with delay function

I wonder how I can make button → delay 7 sec → LED ?
I tried delay function and timer I cannot make any delay. The program should work in this way: I press the button and after 7 seconds LED / pin D13/ will go on.
Thank you

use “debounce” boolean or number


How did you try to code it? Does the LED ever need to go off?

You need a way to remember what state the LED is in. If it is only on/off, then the easiest solution is a flip-flop node. If you never need to turn the LED off, you can do something like this:
The delay timer starts when button is pressed, when delay time is DONE, the flip-flop is turned on, which turns on the LED.

If you want to turn the LED off with the same 7-second delay, use flip-flop-TGL instead of flip-flop-SET. This will have unexpected behavior if you press the button before a 7-second delay has expired (delay will reset, so you “loose” the previous button press).

If you want to turn off LED with same button, but with no delay (or delay different than 7-second), things get a little more complicated, but it can still be done. You will need to change the program flow (or just the value of delay-T) based on the state of the flip-flop.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.