Pauses the program for the amount of time (in microseconds) specified by the parameter. There are a thousand microseconds in a millisecond and a million microseconds in a second.
The largest value that will produce an accurate delay is 16383; larger values can produce an extremely short delay. For delays longer than a few thousand microseconds, you should use delay() instead.
Use the following function to start a pause of a given time in microseconds:
delayMicroseconds(us)
The function admits the following parameter:
us: the number of microseconds to pause. Allowed data types: unsigned int.
The function returns nothing.
The code configures pin number 8 to work as an output pin. It sends a train of pulses of approximately 100 microseconds period. The approximation is due to execution of the other instructions in the code.
int outPin = 8; // digital pin 8
void setup() {
pinMode(outPin, OUTPUT); // sets the digital pin as output
}
void loop() {
digitalWrite(outPin, HIGH); // sets the pin on
delayMicroseconds(50); // pauses for 50 microseconds
digitalWrite(outPin, LOW); // sets the pin off
delayMicroseconds(50); // pauses for 50 microseconds
}
This function works very accurately between 3 and 16383 microseconds. We cannot assure that delayMicroseconds will perform precisely for smaller delay times. Larger delay times may result in a very brief delay.