Why the delay of 10 seconds is not constant value, it is increasing ?
I am using arduino nano version 3. I set 9600 bps
void loop() {
serialPrint("Saaabbb--hghgE");
}
void serialPrint(String message){
Serial.println(millis());
Serial.println(message);
delay(10000);
}
OUTPUT
0
Saaabbb--hghgE
10000
Saaabbb--hghgE
20000
Saaabbb--hghgE
30001
Saaabbb--hghgE
40001
Saaabbb--hghgE
50001
Saaabbb--hghgE
60002
Saaabbb--hghgE
70003
Saaabbb--hghgE
80004
Saaabbb--hghgE
90004
Saaabbb--hghgE
100004
Saaabbb--hghgE
110005
Saaabbb--hghgE
120006
Saaabbb--hghgE
130007
Saaabbb--hghgE
140007
Saaabbb--hghgE
150007
The extra 1 added every couple of commands is the delay caused by actually processing your code. Serial.println(millis())
takes time to complete so the total time is process time + your added delay.
For example:
void loop() {
serialPrint("Saaabbb--hghgE");
}
void serialPrint(String message){
Serial.println(millis()); //takes 0.5millis (for example)
Serial.println(message); //takes 0.5millis (for example)
delay(10000); //takes 10000millis
}
Therefore total time from millis()
is 10001.
Yeah it's just the time needed to process your command. I don't know your project, but since my ones never needed the accuracy of a millisecond, I think you can just ignore it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.