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

当前,可以产生准确延迟的最大值是16383,这可能会在将来的Arduino版本中改变,对于超过几千微秒的延迟,应改为使用delay()函数。

delayMicroseconds - 语法

delayMicroseconds (us) ;

其中, us 是要暂停的微秒数(无符号整数)

delayMicroseconds - 示例

/* 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 连接到数字引脚 13

void setup() {
   pinMode(ledPin, OUTPUT); //将数字引脚设置为输出
}

void loop() {
   digitalWrite(ledPin, HIGH); //将 LED 设置为打开
   delayMicroseconds(1000); //等待一秒钟
   digitalWrite(ledPin, LOW); //关闭 LED
   delayMicroseconds(1000); //等待一秒钟
}

参考链接

https://www.learnfk.com/arduino/arduino-delaymicroseconds-function.html