pxt-calliope/docs/reference/pins/pulse-duration.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

669 B

Pulse Duration

Gets the duration of the last pulse in microseconds.

This function should be called from an on pulsed handler.

pins.pulseDuration();

Returns

The duration of the last pulse, measured in microseconds.

Example

The following example waits for pin P0 to be pulsed high, and then displays the duration of the pulse in microseconds on the LED screen.

pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
    basic.showNumber(pins.pulseDuration());
});

See also

servo set pulse, on pulsed, digital read pin