目录

delayMicroseconds () function

delayMicroseconds()函数接受单个整数(或数字)参数。 此数字表示时间,以微秒为单位。 一毫秒内有一千微秒,一秒钟就有一百万微秒。

目前,可以产生准确延迟的最大值是16383.这可能会在未来的Arduino版本中发生变化。 对于长度超过几千微秒的延迟,您应该使用delay()函数。

delayMicroseconds() function Syntax

delayMicroseconds (us) ;

其中, us是要暂停的微秒数(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
}
↑回到顶部↑
WIKI教程 @2018