Arduino Programming Language: DelayMicroseconds

Name

delayMicroseconds()

Description

This function pauses the program for a specified amount of time, expressex in microseconds.

Syntax

delayMicroseconds(microseconds);

Parameters

  • microseconds: unsigned long containind the amount of time expressed in microseconds to delay the program

Returns

none 

Usage

Application

Note

For Arduino M0 and M0 Pro only

This function stops the program execution for an amount of time (expressed in microseconds) given as a parameter. 

For values below 20 microseconds this function is not accurated. Its maximum error is about 500 nS. 
Between 20 and 60 microseconds the maximum error is about 400 nS. Above 60 microseconds this function gives the maximum accuracy. 
For a long pause (e.g. 10000 microseconds or more) we advise to use the delay function.

Examples

// The blink sketch well explain the delay function
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}

void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delayMicroseconds(5000); // wait
digitalWrite(ledPin, LOW); // sets the LED off
delayMicroseconds(5000); //wait
}

Related Functions


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc