You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • At the moment there isn't a direct replacement. You can do:

    digitalWrite(pin, 1);
    setTimeout(function() {
      digitalWrite(pin, 0);
      setTimeout(function() {
       ...
      }, 0.35);
    },0.35);
    

    or you can do:

    digitalPulse(pin,1,0.35); 
    

    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:

    digitalPulse(pin,1,0.35); 
    digitalPulse(pin,0,0.35); 
    

    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.

About

Avatar for Gordon @Gordon started