You are reading a single comment by @maze1980 and its replies. Click here to read the full conversation.
  • The blocks "After n seconds do" and "Every n seconds do" are suited for the task, like this:

    Every 2 seconds do
    ----After 1 seconds do
    --------print "LED 1 off"
    ----print "LED 2 on"
    

    And yes, it first prints "LED 1 on" and then "LED 1 off", and that makes complete sense. If you tell someone to switch the light out after 1 minute from now on, and then to switch the lights on immediately the exact same thing will happen: Lights on first, then lights off. So I'd say even kids can understand this.

    Now duplicate the block, multiply the numbers by 2.5 and update the text. The kids will see the real power of async programming. You could toggle one LED at 1 Hz and another one at 2.5 Hz. How would you do this with a while loop using waits?

    The wait block should be removed for Espruino as it doesn't do anything useful, Javascript being an async progamming language.

  • being an async progamming language.

    do you mean javascript ES7 which supports async / await changed the nature of language?

About

Avatar for maze1980 @maze1980 started