argument of arduino microsecond delay

Thread Starter


Joined Oct 13, 2018
hi all, I have no problems when entering a constant into the argument of a delay function. but when I enter a variable I can't get any result at all. Here is an example of what I mean.
digitalWrite(11, HIGH);
digitalWrite(11, LOW);
Now if I put a variable in place of the 15 and 25 I just get mv voltage at pin11. The above program gives a pseudo analog voltage. To get a different voltage all you have to do is change the constants. But it is not working for a variable in place of the constants Why?
I am using the arduino nano board.
Last edited:


Joined Jan 30, 2016
Although its not stated explicitly there are several examples that demonstrate that delayMicroseconds() takes a single unsigned integer constant value between 4 and 16384 and not a variable. I found this out myself the hard way too (though I've not tried using it with a declared constant variable). So:

delayMicroseconds(10); //works OK

#define DLY 10
delayMicroseconds(DLY); //works OK

const unsigned int x = 10;
delayMicroseconds(x); //not tried this, but should work

unsigned int y = 10;
delayMicroseconds(y); //tried this, definitely doesn't work for me