setInterval & setTimeout not working as expected

Posted on
  • I followed the quickstart and the setInterval command doesn't work - the led doesn't flash

    I can turn it on and off with toggle() -- but setInterval doesn't call toggle?

    getTIme() is incrementing as I call it

    I expected setTimeout(getTime,1024) to output the time in a second

    it didn't...

    my startup says:

              |_| http://espruino.com
     1v81 Copyright 2015 G.Williams
    

    what am I doing wrong?

    thanks
    al;

    ( I'm a long time javascript developer, so I'm very confused when something this simple doesn't work )

  • Can you tell us what code you're running?

    Also, how are you sending it, by typing in lefthand side, or entering in righthand side and clicking send to Espruino?

    Also, what board are you using?

  • sorry, a pico

    typing into the lift side: setTimeout(getTime,1024)

    nothing happens a second later

  • Hi,

    I think your problem is that you are getting the time after 1.024 seconds, but are just not printing it.

    If you want to print it you could try:

    setTimeout(function() {
      console.log(getTime());
    },1024)
    
  • Nope, that didn't do it... I got it working now, but I don't know what the problem was...

    I use a little powered hub to extend my USB ports to a more comfortable location.

    This morning I tried removing that hub and using it direct into my USB port -- and it worked.

    So I put the hub back in and tried it again in the hub, and it didn't work -- so I tried it in a different slot on the hub and it worked. Then again in slot #3 and it didn't work, then the rest of the slots and it did work. And now it's working in slot #3.

    I don't have any polite words I can use, so I'll just say thanks to everyone who tried to help!

    :)

    Al;

  • Usb hub voodoo. I had a hub like that. The ports went one by one, failing for more and more devices, until nothing worked in any port.

  • I don't have any polite words I can use,...

    ...and that's why grown ups just move on! ;-)

    (move on by crativity)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

setInterval & setTimeout not working as expected

Posted by Avatar for user58511 @user58511

Actions