我想找...

搜尋

分享

目錄

delayMicroseconds()

[Time]

描述

Pauses the program for the amount of time (in microseconds) specified as parameter. There are a thousand microseconds in a millisecond, and a million microseconds in a second.

Currently, the largest value that will produce an accurate delay is about 4000000. This could change in future 86Duino releases. For delays longer than a few seconds, you should use delay() 來代替。

語法

delayMicroseconds(us)

參數

us: the number of microseconds to pause (unsigned int)

回傳

None

範例程式碼

int outPin = 8;                 // digital pin 8
 
void setup()
{
  pinMode(outPin, OUTPUT);      // sets the digital pin as output
}
 
void loop()
{
  digitalWrite(outPin, HIGH);   // sets the pin on
  delayMicroseconds(50);        // pauses for 50 microseconds      
  digitalWrite(outPin, LOW);    // sets the pin off
  delayMicroseconds(50);        // pauses for 50 microseconds      
}

configures pin number 8 to work as an output pin. It sends a train of pulses with 100 microseconds period.

Caveats and Known Issues

In general, this function works accurately in the range 1 microsecond and up. But since delayMicroseconds() doesn’t disable interrupts, we cannot assure that it will always perform precisely for smaller delay-times.

參考


語法參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール