micros()
描述
回傳從 86Duino 開始運行程式到目前所經過的時間,單位是微秒;這個時間大約會在 70 分鐘後溢位 (回到零)。
註解:1000 微秒 = 1 毫秒,1000000 微秒 = 1 秒。
參數
無
回傳
程式開始執行至目前所經過的時間,以微秒為單位 (unsigned long)
範例
unsigned long time;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("Time: ");
time = micros();
// 印出程式執行的時間
Serial.println(time);
// 等待一秒讓資料不致輸出過多
delay(1000);
}
See also
- millis()
- delay()
- delayMicroseconds()
本頁由熱血青年 LBU 譯自英文版。
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
