使程序暂停指定的一段时间(单位:微秒)。一秒等于1000000微秒。 目前,能够产生的最大的延时准确值是16383。对于超过几千微秒的延迟,你应该使用delay()代替。
delayMicroseconds(us)
us:暂停的时间,单位微秒(unsigned int)
无
int outPin = 8; // digital pin 8 void setup() { pinMode(outPin,OUTPUT); //设置为输出的数字管脚 } void loop() { digitalWrite(outPin,HIGH); //设置引脚高电平 delayMicroseconds(50); // 暂停50微秒 digitalWrite(outPin, LOW); // 设置引脚低电平 delayMicroseconds(50); // 暂停50微秒 }
将8号引脚配置为输出脚。它会发出一系列周期100微秒的方波。
此函数在3微秒以以上工作的非常准确。我们不能保证,delayMicroseconds在更小的时间内延时准确。