# Time in Arduino programming with examples

## Time in Arduino:

Arduino Time- in this article, I am going to show you how to use the time function in Arduino with programming examples

## Time Functions in Arduino:

These instructions do not belong to any object, so they are written directly:

### millis():

this Arduino time returns the number of milliseconds (ms) since the Arduino board started running the current sketch. This number will reset to zero after approximately 50 days (when its value exceeds the maximum allowed by its type, which is “unsigned long”). It has no parameters.

### micros():

this Arduino time function returns the number of microseconds (µs) since the board Arduino started running the current sketch. This number –of type “unsigned long ”- will reset to zero after approximately 70 minutes. This instruction has a resolution of 4 µs (that is, the returned value is always a multiple of four). Remember that 1000 µs is a millisecond and therefore, 1000000 µs is one second. It has no parameters.

### delay():

this Arduino time pauses the sketch for the specified number of milliseconds as a parameter –of type “unsigned long”.It has no return value.

### delayMicroseconds():

this Arduino time pauses the sketch for the number of microseconds specified as a parameter –of type “unsigned long”.Currently, The maximum value that can be used with precision is 16383. To wait greater than this, it is recommended to use the delay() instruction. The minimum value that can be used accurately is 3 µs. It has no return value.

## Examples of Arduino time functions:

### Example1: how to usemicros()function of time in Arduino programming:

Output: As you can see by the “Serial monitor” how it goes increasing the time that passes since the sketch started. The value observed increases approximately one second at a time.

### Example2: how to usemillis()function of time in Arduino programming:

Output: In the above code you can see a way to count the time elapsed between two specific moments. The procedure is to save in a variable the value returned by millis() at the initial time, and save in another different variable the value returned by millis() at the final time, to then subtract one from the other and thus find out the elapsed time.

## Related Articles:

### Recommended For You 