You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • The Pico is correct :)

    On the Pico, the code executes quick enough that console.log('newtime ', newtime); is executed before the timeout created with setTimeout executes, so newtime 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);
    
About

Avatar for Gordon @Gordon started