Arduino - delayMicroseconds () 函数
delayMicroseconds() 函数接受一个整数(或数字)参数。此数字表示时间,以微秒为单位。一毫秒为一千微秒,一秒为一百万微秒。
目前,可以产生准确延迟的最大值是 16383。这可能会在未来的 Arduino 版本中发生变化。对于超过几千微秒的延迟,您应该改用 delay() 函数。
delayMicroseconds() 函数语法
delayMicroseconds (us) ;
其中,us 是暂停的微秒数(无符号整数)
示例
/* 闪烁的 LED * ------------ * 以 1 秒为间隔打开和关闭连接到数字引脚的发光二极管 (LED)。 * */ int ledPin = 13; // 连接到数字引脚 13 的 LED void setup() { pinMode(ledPin, OUTPUT); // 将数字引脚设置为输出 } void loop() { digitalWrite(ledPin, HIGH); // 将 LED 设置为打开 delayMicroseconds(1000); // 等待一秒 digitalWrite(ledPin, LOW); // 将 LED 设置为关闭 delayMicroseconds(1000); // 等待一秒 }