这里会显示出您选择的修订版和当前版本之间的差别。
前一修订版后一修订版 | |||
— | reference:language:delaymicroseconds [2017/04/07 10:03] – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== delayMicroseconds() ====== | ||
+ | |||
+ | ===== 描述 ===== | ||
+ | |||
+ | 使程序暂停指定的一段时间(单位:微秒)。一秒等于1000000微秒。 | ||
+ | 目前,能够产生的最大的延时准确值是16383。这可能会在未来的ocrobot版本中改变。对于超过几千微秒的延迟,你应该使用delay()代替。 | ||
+ | ===== 语法 ===== | ||
+ | |||
+ | delayMicroseconds(us) | ||
+ | ===== 参数 ===== | ||
+ | |||
+ | us: | ||
+ | ===== 返回 ===== | ||
+ | |||
+ | 无 | ||
+ | ===== 例子 ===== | ||
+ | <code cpp> | ||
+ | int outPin = 8; // digital pin 8 | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | pinMode(outPin,OUTPUT); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | digitalWrite(outPin,HIGH); | ||
+ | delayMicroseconds(50); | ||
+ | digitalWrite(outPin, | ||
+ | delayMicroseconds(50); | ||
+ | } | ||
+ | </ | ||
+ | 将8号引脚配置为输出脚。它会发出一系列周期100微秒的方波。 | ||
+ | ===== 警告和已知问题 ===== | ||
+ | |||
+ | 此函数在3微秒以以上工作的非常准确。我们不能保证,delayMicroseconds在更小的时间内延时准确。 | ||
+ | |||
+ | |||