time delay input-output

Hi! first post, newbie here.. :stuck_out_tongue:
I have one input and one output. Lets say IN, and OUT. Both are HIGH
All I want is:

If IN=LOW for time<1sec then OUT=LOW for 3 secs
and
if IN=LOW for time>1sec, thenOUT=LOW as long as IN=LOW

How can I achieve that? My programming skills are inadequate.. :~ Any help appreciated

Thanks!!

It is not as easy as it sounds, you have in effect a re-triggriable monostable. You are much better off using a NE555 chip to do this than wasting a whole arduino.

It's just a part of a bigger project, so I'm planning to add it to Arduino..
I understand that it is not just 3-4 lines of code, that's why I asked for help.
Thanks anyway!

You will need to understand the blink without delay example, or search for state machine.
When you detect a low input set the output low and make a note of the time. Then each time round the loop you see if the current time minuse the time the push happened is greater than three seconds, if it is you then look to see if the push button has been released. If it has then set the output high if not then just keep looking at the input until it is released. Set the output high whe. This happens.
Implement all this with a state machine.

Thank you for your help! Your advice was useful, I managed to do it after some research. :slight_smile: