Go Down

Topic: Seconds function? (Read 2335 times) previous topic - next topic



My Arduino code is full of stuff, including delays. In this, I want a second counter to be running from when the script starts. Is there any function I could use that does this, as I can't have it in my void loop due to many other delays?



millis() returns the number of milliseconds elapsed since your sketch started.

Don't send me technical questions via Private Message.


There are provided functions millis, and micros.
Check the Arduino reference http://arduino.cc/en/Reference/HomePage

Also load up the 'blink without delay' example code in the IDE to see how you can cause events to happen after a certain time rather than delaying.

There are many topics covering the many ways of managing multiple tasks, tons are here on the forum.

Forum Mod anyone?


You can do a shortcut like:

#define seconds() (millis()/1000)

Of course this seconds counter wraps around in 49 days just like the millis() wraps around in 49 days.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter


Go Up