delayMicroseconds()函数接受单个整数(或数字)参数。 此数字表示时间,以微秒为单位。 有一千毫秒在一毫秒,和一百万微秒在一秒钟。
目前,可以产生精确延迟的最大值是16383.这可能会在未来的Arduino版本中改变。 对于超过几千微秒的延迟,应该使用delay()函数。
delayMicroseconds()函数语法
- delayMicroseconds (us) ;
其中, us 是要暂停的微秒数(unsigned int)
例子
- /* 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 connected to digital pin 13
- void setup() {
- pinMode(ledPin, OUTPUT); // sets the digital pin as output
- }
- void loop() {
- digitalWrite(ledPin, HIGH); // sets the LED on
- delayMicroseconds(1000); // waits for a second
- digitalWrite(ledPin, LOW); // sets the LED off
- delayMicroseconds(1000); // waits for a second
- }
转载本站内容时,请务必注明来自W3xue,违者必究。