当前位置: 首页 > 文档资料 > Arduino 中文教程 >

millis () function

优质
小牛编辑
121浏览
2023-12-01

此函数用于返回当时的毫秒数,Arduino板开始运行当前程序。 这个数字溢出,即大约50天后回到零。

millis() function Syntax

millis () ;

此函数返回从程序开始的毫秒数。

例子 (Example)

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