2019-01-03 16:02:19 -08:00
# pulse Duration
2016-07-06 11:54:42 -07:00
2019-01-03 16:02:19 -08:00
Get the duration of the last pulse in microseconds.
2016-07-06 11:54:42 -07:00
```sig
pins.pulseDuration();
```
2019-01-03 16:02:19 -08:00
A pin pulse is detected in the [onPulsed ](/reference/pins/on-pulsed ) event. You use **pulseDuration** inside that event to get the duration of the pulse that triggered the event.
### ~ hint
**Simulator**: This function needs real hardware to work with. It's not supported in the simulator.
### ~
2017-09-07 13:42:08 -07:00
## Returns
2016-07-06 11:54:42 -07:00
2019-01-03 16:02:19 -08:00
* a [number ](/types/number ) that is the duration of the last pulse, measured in microseconds.
2016-07-06 11:54:42 -07:00
2017-09-07 13:42:08 -07:00
## Example
2016-07-06 11:54:42 -07:00
2019-01-03 16:02:19 -08:00
Wait for pin ``P0` ` to be pulsed high. Display the duration of the pulse in microseconds on the LED screen.
2016-07-06 11:54:42 -07:00
```blocks
pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
basic.showNumber(pins.pulseDuration());
});
```
2017-09-07 13:42:08 -07:00
## See also
2016-07-06 11:54:42 -07:00
[servo set pulse ](/reference/pins/servo-set-pulse ),
[on pulsed ](/reference/pins/on-pulsed ),
[digital read pin ](/reference/pins/digital-read-pin )