Micros()

来自YFRobotwiki
跳转至: 导航搜索

描述

返回自Arduino板开始运行当前程序以来的微秒数。 大约70分钟后,这个数字会溢出(返回到零)。 在16 MHz Arduino板(例如Duemilanove和Nano)上,该功能的分辨率为4微秒(即返回的值始终为4的倍数)。 在8 MHz Arduino板(例如LilyPad)上,此功能的分辨率为8微秒。

注意:毫秒内有1000微秒,一秒钟有1,000,000微秒。


参数

None


返回

程序启动后的微秒数(unsigned long)


示例

unsigned long time;

void setup(){
  Serial.begin(9600);
}
void loop(){
  Serial.print("Time: ");
  time = micros();
  //prints time since program started
  Serial.println(time);
  // wait a second so as not to send massive amounts of data
  delay(1000);
}


扩展阅读

- millis()
- delay()
- delayMicroseconds()




返回Arduino语法参考列表

更多建议和问题欢迎反馈至 YFRobot论坛