Except that the language is supposed to be easy to use for beginners. The function dumbs down the resolution to 1 us from .25 us (ostensibly to make it easier to use) so what the heck is one more check. (.25 us?).

Anyone using the language could easily expect delayMicroseconds(0) to generate as-close-to-zero-as-possible a delay not 1023 us.

BTW - negative numbers are also going to generate long delays I think. Checking for errors in this function makes for one more place the code can't screw up. If you want to argue for efficient machine code fine - but you've got to explain all the other inefficiencies, of which the 1 us resolution is only one. And also the stated philosohpy of making something for beginner coders.

It's been traumatic for certain parties to even see documentation of C and AVR arcana in the reference section.

I repeat - fix this ______ instead of documenting it.

if (--us < 2)return;

Doesn't that fix it? Predecrement and one comparison. You've got your predecrement to bring to the party!

Would making the parameter a signed long also fix negative numbers this way? How does that playout with the right bitshift 2 dumbdown (er ease of use feature)

Anyway the rumor is that we're due to get a whole new timing system for Arduino 0011. Is this still on track?

All of the numbers jitter randomly by one or two, presumably because of interrupt firings or serial.print or some other unknown (to me) phenomenon.

Please replicate my results on this if you care, then can we finally fix the code and move on?

A more patient math-head than me might also want to see if the function is as advertised, with about 1 us going into the function overhead.

There is another decrement farther down in the code that could be combined with the decrement to tweak timing. Should anyone care to get into it. I imagine it's only going to be possible to confirm this through some patient work with an oscilloscope or through sorting through the machine code and counting instructions, though. I'm not up for either at this point.

I'm writing to see if I can get some of the amazing coders who are currently reading this list to test this proposed fix and confirm my results. It's possible that the fix works differently now since it was last tested with Arduino 10/11.

According to my results this fix is FREE and works EXACTLY LIKE THE ORIGINAL function except without the nasty surprise when using zero or neg numbers for a parameter.

Perhaps someone could decompile and look at the machine code to confirm that the two are equivalent.

If this is the case, then the reason for leaving in this irritating bug in a language / project whose stated goals is to make programming easy for beginners is perplexing. Or at least it tends to make one wonder if there are other reasons....