Arduino millis()

https://www.w3cschool.cn/arduino/arduino_millis_function.html

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

“4294967295”相当于50天

if((millis()-4294967295UL )>100UL){}

 'u' or 'U' 指定一个常量为无符号型。(只能表示正数和0) 例如: 33u 'l' or 'L' 指定一个常量为长整型。(表示数的范围更广) 例如: 100000L 'ul' or 'UL' 这个你懂的,就是上面两种类型,称作无符号长整型。

例如:32767ul

millis()函数语法

unsigned long millis(void);

 

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

例子

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); }

 

posted @ 2019-01-10 09:35  chenlife  阅读(1089)  评论(0)    收藏  举报