🌐
Arduino Getting Started
arduinogetstarted.com › reference › arduino-micros
micros() | Arduino Getting Started
June 5, 2026 - the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds.
🌐
DeepBlue
deepbluembedded.com › home › blog › arduino micros() function – (millis vs micros)
Arduino Micros() Function - (millis vs micros)
August 17, 2023 - Be advised that the Arduino micros() ... than this. In this example project, we’ll create a time delay using the Arduino micros() function instead of the delay() function....
🌐
TutorialsPoint
tutorialspoint.com › arduino › arduino_micros_function.htm
Arduino - micros () function
This number overflows i.e. goes back to zero after approximately 70 minutes. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e.
🌐
Arduino
docs.arduino.cc › language-reference › en › functions › time › micros
micros() | Arduino Documentation
June 5, 2025 - This function returns the number of microseconds since the Arduino board began running the current program.
🌐
The Robotics Back-End
roboticsbackend.com › home › arduino millis() vs micros()
Arduino millis() vs micros() - The Robotics Back-End
October 11, 2021 - The resolution for micros() is 4 microseconds on all 16MHz Arduino boards: Uno, Mega, Nano, etc. For example, if you read the time with micros() and get 10000, then the next value you get is 10004, and after that 10008, and so on.
🌐
Wordpress
ucexperiment.wordpress.com › 2012 › 03 › 17 › examination-of-the-arduino-micros-function
Examination of the Arduino micros() Function | µC eXperiment
July 28, 2016 - Both the millis() and micros() functions base their calculations on the Arduino Timer #0, which is running with a prescale of 64. This results in the timer ticking at 64*1/16,000,000th of a second (which is 0.000004 seconds or evey 4 µs).
🌐
Mechatronics LAB
mechatronicslab.net › home › lessons › arduino programming handbook › 16 timers & delays › 16.4 using micros() for microsecond resolution in arduino programming
16.4 Using micros() for Microsecond Resolution in Arduino Programming - Mechatronics LAB
Safety Notes When dealing with timing-sensitive hardware, always confirm the required resolution. Some tasks may not need microsecond precision, and using it unnecessarily can complicate your code. Try It Yourself Project: Measuring LED Toggle Speed · Project Overview We’ll measure how fast the Arduino can turn an LED on and off using micros().
🌐
Zbotic
zbotic.in › home › arduino timer tutorial: millis(), micros() & hardware timers
Arduino Timer Tutorial: millis(), micros() & Hardware - Zbotic
March 11, 2026 - On a 16 MHz Arduino Uno, millis() has a resolution of approximately 1.024 ms (due to Timer0 prescaler settings). It does not tick exactly every 1.000 ms — there’s a small accumulated drift. For timing requirements tighter than ~1 ms, use micros() which has 4 µs resolution.
Find elsewhere
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Arduino micros function - Programming - Arduino Forum
May 9, 2020 - The function (which I found on a forum): unsigned long micros() { unsigned long m; uint8_t oldSREG = SREG, t; cli(); m = timer0_overflow_count; #if defined(TCNT0) t = TCNT0; #elif defined(TCNT0L) t = TCNT0L; #else #error TIMER 0 not defined #endif #ifde......
🌐
Delft Stack
delftstack.com › home › howto › arduino › arduino delay microseconds
How to Add Delay in Microseconds in Arduino | Delft Stack
March 4, 2025 - In this example, we toggle the LED state every 1000 microseconds (1 millisecond). We use micros() to check the elapsed time since the last toggle. This non-blocking approach allows the Arduino to perform other tasks while still managing precise ...
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Yet Another Tutorial On Timing With millis()/micros() - Programming - Arduino Forum
October 18, 2017 - Since I've had success with developing an idea to preproduction prototype stage using Arduinos, I'm giving back to the community by spamming several subfora with things I've worked out through my dev process that I know people have asked about. ("I know people asked about" because I also asked, ...
🌐
Arduino
docs.arduino.cc › hardware › micro
Micro | Arduino Documentation
The Micro runs on an ATmega32u4 processor with native USB communication. Configure via software whether the board is recognised as a standard Arduino, a mouse or keyboard.
🌐
Arduino
docs.arduino.cc › language-reference › funções › time › micros
micros()
The official Arduino programming language structure reference pages.
🌐
Instructables
instructables.com › circuits › arduino
How to Get an Arduino Micros() Function With 0.5us Precision : 5 Steps - Instructables
October 17, 2017 - How to Get an Arduino Micros() Function With 0.5us Precision: I love Arduino microcontroller programming, and I regularly use it in aerospace research, as well as in home projects. As I work on my many home projects, however, I frequently find myself needing a very precise timer.
🌐
Circuit Geeks
circuitgeeks.com › home › arduino millis() and micros()
Arduino millis() and micros()
March 2, 2022 - So we can count up to 49.71 days [4,294,967,295/(1000*3600*24)] continuously after that it will reset to 0. This can become a problem for some projects. micros() counts in microseconds and there are 1000,000 microseconds in a second.
Top answer
1 of 4
21

The other answers are very good, but I want to elaborate on how micros() works. It always reads the current hardware timer (possibly TCNT0) which is constantly being updated by the hardware (in fact, every 4 µs because of the prescaler of 64). It then adds in the Timer 0 overflow count, which is updated by a timer overflow interrupt (multiplied by 256).

Thus, even inside an ISR, you can rely on micros() updating. However if you wait too long then you miss the overflow update, and then the result returned will go down (i.e you will get 253, 254, 255, 0, 1, 2, 3 etc.)

This is micros() - slightly simplified to remove defines for other processors:

unsigned long micros() {
    unsigned long m;
    uint8_t oldSREG = SREG, t;
    cli();
    m = timer0_overflow_count;
    t = TCNT0;
    if ((TIFR0 & _BV(TOV0)) && (t < 255))
        m++;
    SREG = oldSREG;
    return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}

The code above allows for the overflow (it checks the TOV0 bit) so it can cope with the overflow while interrupts are off but only once - there is no provision for handling two overflows.


TLDR;

  • Don't do delays inside an ISR
  • If you must do them, you can time then with micros() but not millis(). Also delayMicroseconds() is a possibility.
  • Don't delay more than 500 µs or so, or you'll miss a timer overflow.
  • Even short delays may cause you to you miss incoming serial data (at 115200 baud you will get a new character every 87 µs).
2 of 4
9

It is not wrong to use millis() or micros() within an interrupt routine.

It is wrong to use them incorrectly.

The main thing here is that while you are in an interrupt routine "the clock isn't ticking". millis() and micros() won't change (well, micros() will initially, but once it goes past that magic millisecond point where a millisecond tick is required it all falls apart.)

So you can certainly call on millis() or micros() to find out the current time within your ISR, but don't expect that time to change.

It is that lack of change in the time that is being warned about in the quote you provide. delay() relies on millis() changing to know how much time has passed. Since it doesn't change delay() can never finish.

So essentially millis() and micros() will tell you the time when your ISR was called no matter when in your ISR you use them.

🌐
Energia
energia.nu › reference › en › language › functions › time › micros
micros()
the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds.
🌐
Arduino
store-usa.arduino.cc › collections › arduino micro
Arduino Micro with Headers | Compact USB Dev Board — Arduino Online Shop
Arduino Micro
You can find in the Getting started with the Arduino Micro section all the information you need to configure your board, use the Arduino Software (IDE), and start tinkering with coding and electronics. From the Tutorials section you can find examples from libraries and built-in sketches as ... The Micro is a microcontroller board based on the ATmega32U4 (datasheet), developed in conjunction with Adafruit. It has 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an ICSP header, and a reset button. I
Rating: 4.6 ​