@JumJum: That'll only work if you're using the version you install from GitHub - not the one from the web store.
@controlCloud: Ok, I just got the out of memory by tapping the button 5 times very quickly - is that what you did?
But yes, the code that's produced is async - when you say 'wait 2 seconds' it actually executes the bit inside it after 2 seconds, while executing the next bit down immediately. So what you're doing is immediately asking 20 different digitalWrites to be done after 2 seconds. If you press the button 5 times that's creating 100 different callbacks!
If you want to flash, then I'd drag the second wait to be inside the first wait. Repeating 10 times is more tricky, but can be done with something like the attached. Obviously if you keep pressing the button it'll have pretty much the same effect and will run out of memory though (however after roughly twice the number of button presses).
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.
@JumJum: That'll only work if you're using the version you install from GitHub - not the one from the web store.
@controlCloud: Ok, I just got the out of memory by tapping the button 5 times very quickly - is that what you did?
But yes, the code that's produced is async - when you say 'wait 2 seconds' it actually executes the bit inside it after 2 seconds, while executing the next bit down immediately. So what you're doing is immediately asking 20 different digitalWrites to be done after 2 seconds. If you press the button 5 times that's creating 100 different callbacks!
If you want to flash, then I'd drag the second wait to be inside the first wait. Repeating 10 times is more tricky, but can be done with something like the attached. Obviously if you keep pressing the button it'll have pretty much the same effect and will run out of memory though (however after roughly twice the number of button presses).
1 Attachment