You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi Frida,

    So I think you actually mean:
    digitalPulse(LED1, 1, 1200)

    This is expected... So what happens is that digitalPulse sets the pin to 1, then starts a timer in the background, which sets the pin low after 1200ms = 1.2 seconds.

    If you then call digitalPulse again, it waits for the first timer to finish before it starts the next pulse. Rather than hang the device, it only waits around a second for the pulse before giving up and raising an error.

    Perhaps it should produce a better error message, but I think the behaviour is right. If you typed digitalPulse(LED1, 1, 100000000000) you wouldn't want the device to just stop working while it waited.

    digitalPulse is for short 'pulses' that need to be very accurate. For longer pulses, use setTimeout instead.

About

Avatar for Gordon @Gordon started