This is an old revision of the document!


Table of Contents

Timing

There are two functions for the use of timing in the code of Arduino - delay() and millis().

Delay()

The delay() function pauses the execution of a program for a determined amount of time that is defined by milliseconds in the brackets. The down side of the delay() function is that none of the other program functions can execute while the time defined in the function is not passed.

The Delay() function also has the version that is using microseconds instead of milliseconds and it is called - delayMicroseconds().

Millis()

The millis() function works a bit differently, because it returns the amount if milliseconds that have passed since the program was started. millis() function is often used to determine the interval of time and to check if it has passed. One of the benefits of using millis() is that the program is not paused until the time interval will pass and any other functions can still execute. The second benefit is better accuracy in timing than using Delay() function.

This function also has the version of using microseconds instead of milliseconds - micros()

en/iot-open/programming_fundamentals_rtu/timing.1517393993.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0