From a4eccaf4f93e4f18d9785bbd2746a9bbbfac568d Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Wed, 6 Jul 2016 11:54:42 -0700 Subject: [PATCH] Wrote new advanced topic --- docs/reference/pins/pulse-duration.md | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 docs/reference/pins/pulse-duration.md diff --git a/docs/reference/pins/pulse-duration.md b/docs/reference/pins/pulse-duration.md new file mode 100644 index 00000000..b5277359 --- /dev/null +++ b/docs/reference/pins/pulse-duration.md @@ -0,0 +1,30 @@ +# Pulse Duration + +Gets the duration of the last pulse in microseconds. + +This function should be called from an **on pulsed** handler. + +```sig +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. + +```blocks +pins.onPulsed(DigitalPin.P0, PulseValue.High, () => { + basic.showNumber(pins.pulseDuration()); +}); +``` + +### See also + +[servo set pulse](/reference/pins/servo-set-pulse), +[on pulsed](/reference/pins/on-pulsed), +[digital read pin](/reference/pins/digital-read-pin)