delayMicroseconds()函数接受一个整数(或数字)参数,该数字表示时间,以微秒为单位,一毫秒有一千微秒,一秒有一百万微秒。
当前,可以产生准确延迟的最大值是16383,这可能会在将来的Arduino版本中改变,对于超过几千微秒的延迟,应改为使用delay()函数。
链接:https://www.learnfk.comhttps://www.learnfk.com/arduino/arduino-delaymicroseconds-function.html
来源:LearnFk无涯教程网
delayMicroseconds (us) ;
其中, us 是要暂停的微秒数(无符号整数)
/* 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); //等待一秒钟 }
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)