You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Ahh, well what you'd want to do with setInterval is something like this:

    setInterval(function() {
      digitalWrite(pin,1);
      setTimeout(function() {
        digitalWrite(pin,0);
      }, 2); // 2ms @ 100Hz = 20%
    }, 10); // 100 Hz
    

    (So you use a setInterval for each full cycle, and then setTimeout for each pulse)

    Or you could use the built-in digitalPulse:

    setInterval(function() {
      digitalPulse(pin,1,2); // 2ms @ 100Hz = 20%
    }, 10); // 100 Hz
    

    Hopefully those should work on anything

About

Avatar for Gordon @Gordon started