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.
