From 9f1c3ee13ce3753018a9d5c053b69936e0cf2095 Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Tue, 5 Jul 2016 14:04:12 -0700 Subject: [PATCH] Created advanced topic --- docs/reference/pins/set-pull.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/reference/pins/set-pull.md diff --git a/docs/reference/pins/set-pull.md b/docs/reference/pins/set-pull.md new file mode 100644 index 00000000..23f168aa --- /dev/null +++ b/docs/reference/pins/set-pull.md @@ -0,0 +1,32 @@ +# Set Pull + +Configure the electrical pull of the specified pin. + +Many micro:bit pins can be configured as _pull-ups_. For example, a +pull-up can set a pin's voltage to high (3.3 volts, or `1` when +calling [digital read pin](/reference/pins/digital-read-pin)). If one +end of a button is connected to ``P0`` (set to high) and the other end +is connected to ``GND`` (0 volts), then when you press the button, +``P0`` is driven to 0 volts, and the micro:bit software can detect a +button press. + +```sig +pins.setPull(DigitalPin.P9, PinPullMode.PullDown); +``` + +### Parameters + +* ``pin``: The micro:bit hardware pin to configure (``P0``-``P20``) +* ``to``: The pull to which to set the pin (**down**, **up**, or **none**) + +### Example + +The following example sets the pull of pin ``P0`` to **up** (high). + +```blocks +pins.setPull(DigitalPin.P0, PinPullMode.PullUp); +``` + +### See also + +[BBC micro:bit | mbed](https://developer.mbed.org/platforms/Microbit/)