Go Down

Topic: Temporization without delay (Read 559 times) previous topic - next topic

Davyx

Hi everybody,

First of all, Happy New Year to everybody!

I'm trying to find out how to create a temporization without the delay() function.
If a digital input is set to HIGH, I would like one output stays a certain time (40 seconds in my case) to the HIGH level before going back to LOW, and only one time.
Like I'm running several loops at the same time, if I use the delay() function in one loop, it will also stop all the other loops what I don't want. I tried to use the Millis() function from the Blinking Led example but the output doesn't stop to be HIGH and LOW with a period of 1.2 min.
How can I do?


PaulS

Quote
I tried to use the Millis() function from the Blinking Led example but the output doesn't stop to be HIGH and LOW with a period of 1.2 min.
How can I do?

Using millis() to record when the pin was set HIGH, and then setting it LOW at some later time is the correct approach.

If it failed to work, it is because you didn't turn the pin off at the right time.

Post the code that you are using, and we'll help you figure out what the problem is.

Alternatively, the hard work has been done for you.
http://www.arduino.cc/playground/Code/TimedAction

Go Up