Go Down

Topic: Seconds function? (Read 561 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.



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.


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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131