Arduino - delayMicroseconds() 函式



delayMicroseconds() 函式接受一個整數(或數字)引數。此數字表示時間,並以微秒為單位。毫秒中有 1000 微秒,秒中有 100 萬微秒。

目前,可以產生精確延遲的最大值為 16383。這可能會在未來的 Arduino 版本中發生變化。對於超過幾千微秒的延遲,您應該改用 delay() 函式。

delayMicroseconds() 函式語法

delayMicroseconds (us) ;

其中,us 是要暫停的微秒數(無符號整數)

示例

/* 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
廣告