2016-07-06 20:54:42 +02:00
|
|
|
# Pulse Duration
|
|
|
|
|
|
|
|
Gets the duration of the last pulse in microseconds.
|
|
|
|
|
|
|
|
This function should be called from an **on pulsed** handler.
|
|
|
|
|
|
|
|
```sig
|
|
|
|
pins.pulseDuration();
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Returns
|
2016-07-06 20:54:42 +02:00
|
|
|
|
|
|
|
The duration of the last pulse, measured in microseconds.
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Example
|
2016-07-06 20:54:42 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
|
|
|
|
basic.showNumber(pins.pulseDuration());
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## See also
|
2016-07-06 20:54:42 +02:00
|
|
|
|
|
|
|
[servo set pulse](/reference/pins/servo-set-pulse),
|
|
|
|
[on pulsed](/reference/pins/on-pulsed),
|
|
|
|
[digital read pin](/reference/pins/digital-read-pin)
|