While an interrupt service routine runs, other interrupts are disabled, unless the routine explicitly enables them.
micros() uses the running count of Timer0 overflow interrupts to calculate how many thousands of microseconds have passed.
While your interrupt service routine runs, Timer0 overflow interrupts aren't processed, so the count doesn't advance.
That means that the results of micros() are incorrect. Calculations using those results will yield unexpected results.
If you're sure another Interrupt 0 won't occur while interrupt() runs, you could reenable interrupts inside of it, allowing the Timer0 interrupt service routine to execute. Your delays will be a little long, since they won't account for the time spent servicing the Timer0 overflow ISR.
Alternatively, you could throw a flag in interrupt(), remove the delays from interrupt(), and execute the delays in loop(). That flag could be the value of micros() when the service routine executes; loop() could then just wait until micros() advances by 3000 from that value.
It's generally a bad idea to use any delay - or any blocking call at all - inside an interrupt service routine. Interrupt service routines need to execute quickly, to avoid interfering with other ongoing processes.
The short version: in general you should not use any form of delay inside an interrupt handler.
There are some exceptions, such as when you're trying to perform especially high frequency or low latency actions, but I'd consider that an advanced application and if you're up to that you probably aren't here asking why delays don't work right.
microsmillis() uses the running count of Timer0 overflow interrupts to calculate how many thousands of milliseconds have passed.
That looks like a correction, but I'm not sure what it's correcting. From wiring.c, IDE 1.5.3, as it compiles for the Uno, with declarations, compiler directives and housekeeping snipped for brevity:
unsigned long micros() {
... <snipped>
m = timer0_overflow_count;
t = TCNT0;
if ((TIFR0 & _BV(TOV0)) && (t < 255))
m++;
... <snipped>
return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}
timer0_overflow_count is bumped without further processing in the Timer0 overflow ISR; it's the running count of Timer0 overflows; it's used in calculating the return value of micros(); and it keeps track of - well, not exactly thousands of microseconds, but 1024's of microseconds. micros(), rather than millis(), is the function the OP asked about. The original quote, when I wrote it, said "microseconds," rather than "millseconds," and, as far as I can tell, the original was right. Except for that part about "thousands," that is.
It was a correction.
"micros()" does not calculate how many thousands of milliseconds have passed.
That would be like counting months to see how many hours have passed.
"millis()" counts how many thousands of microseconds have passed.
tmd3:
... how many thousands of microseconds have passed. [emphasis added.]
while the quote from reply #2 says,
AWOL:
... how many thousands of milliseconds have passed. [emphasis mine]
Idly speculating: I don't remember it, but I suspect that I typed the erroneous line and fixed it right away. I can't find an edit tag on reply #1, but I notice that one doesn't attach when I edit something immediately. That makes me suspect that AWOL sees that post by some means other than the one I use, and that the original error maintains a ghostly existence there.