“Millis()”的版本间的差异
来自YFRobotwiki
(以“<font color="orange" size="+1">'''描述'''</font> 返回自Arduino板开始运行当前程序以来的毫秒数。 大约50天后,这个数字会溢出(返回...”为内容创建页面) |
|||
| 第7行: | 第7行: | ||
none | none | ||
| + | |||
<font color="orange" size="+1">'''返回'''</font> | <font color="orange" size="+1">'''返回'''</font> | ||
2017年9月13日 (三) 11:05的最后版本
描述
返回自Arduino板开始运行当前程序以来的毫秒数。 大约50天后,这个数字会溢出(返回零)。
参数
none
返回
程序启动后的毫秒数(unsigned long)
注意
请注意,millis()的返回值是无符号长的,如果程序员尝试使用较小的数据类型(如int)进行算术,则可能会发生逻辑错误。 偶数签名长时间可能会遇到错误,因为其最大值是其未签名的对等方的一半。
示例
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);
}
扩展阅读
更多建议和问题欢迎反馈至 YFRobot论坛