Arduino - millis() 函式



此函式用於返回Arduino板開始運行當前程式時的毫秒數。此數字會溢位,即在大約50天后回到零。

millis() 函式語法

millis () ;

此函式返回程式啟動後的毫秒數。

示例

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); 
}
arduino_time.htm
廣告