-
• #2
The Pico is correct :)
On the Pico, the code executes quick enough that
console.log('newtime ', newtime);
is executed before the timeout created withsetTimeout
executes, sonewtime
doesn't get assigned before it is used.If you want this to actually work, do:
oldtime = getTime(); setTimeout(function() { newtime = getTime(); console.log('oldtime ', oldtime); console.log('newtime ', newtime); console.log('diftime ', newtime-oldtime); },160);
-
• #3
Just to add - the ESP8266 isn't exactly wrong in this case - it's just that I imagine the upload takes longer over serial, and things won't be scheduled quite as well because you're reliant on the underlying RTOS.
With the same code, I have different output on pico and esp8266.
Which one is correct?
I think it is esp8266, but I may be wrong.
code: