What is the reason behind writing tNow = millis();
twice, i.e., once in setup()
and once in void requestData()
?
It should have been tLast = millis()
to initialize it in setup()
as your starting time.
Consider and try tLast = 5000;
initialized in setup()
before starting the thread()
and observe what that will do.
Write some code with millis()
in setup()
(more than once and different locations) and draw()
and use println()
to examine the values.
I write a lot of simple snippets of code to examine how they work and a better programmer for it.
See the references for setup()
and draw()
as well to understand them.
Reference:
:)
1 Like