Which will be substantially more accurate. This actually starts executing subsequent commands (apart from other digitalPulses) before the pulse has ended, so for something more accurate, you could try:
I'm trying to discourage people from writing code that delays (because then they start to get annoyed that Espruino isn't multithreaded), however I think delays do need to be added for this kind of thing - I've put a bug in for it, so hopefully I'll get around to it at some point.
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.
At the moment there isn't a direct replacement. You can do:
or you can do:
Which will be substantially more accurate. This actually starts executing subsequent commands (apart from other digitalPulses) before the pulse has ended, so for something more accurate, you could try:
I'm trying to discourage people from writing code that delays (because then they start to get annoyed that Espruino isn't multithreaded), however I think delays do need to be added for this kind of thing - I've put a bug in for it, so hopefully I'll get around to it at some point.