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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The blocks "After n seconds do" and "Every n seconds do" are suited for the task, like this:
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.