Arduino - delayMicroseconds () function



The delayMicroseconds() function accepts a single integer (or number) argument. This number represents the time and is measured in microseconds. There are a thousand microseconds in a millisecond, and a million microseconds in a second.

Currently, the largest value that can produce an accurate delay is 16383. This may change in future Arduino releases. For delays longer than a few thousand microseconds, you should use the delay() function instead.

delayMicroseconds() function Syntax

delayMicroseconds (us) ;

where, us is the number of microseconds to pause (unsigned int)

Example

/* Flashing LED
   * ------------
   * Turns on and off a light emitting diode(LED) connected to a digital
   * pin, in intervals of 1 seconds. *
*/

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(1000); // waits for a second
   digitalWrite(ledPin, LOW); // sets the LED off
   delayMicroseconds(1000); // waits for a second
}
arduino_time.htm
Advertisements