pxt-calliope/docs/reference/pins/set-pull.md

35 lines
1000 B
Markdown
Raw Normal View History

2016-07-05 23:04:12 +02:00
# Set Pull
Configure the electrical pull of the specified pin.
2016-11-02 01:44:37 +01:00
Many @boardname@ pins can be configured as _pull-ups_. For example, a
2016-07-05 23:04:12 +02:00
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,
2016-11-02 01:44:37 +01:00
``P0`` is driven to 0 volts, and the @boardname@ software can detect a
2016-07-05 23:04:12 +02:00
button press.
```sig
pins.setPull(DigitalPin.P9, PinPullMode.PullDown);
```
The pull-up and -down resistors are about 13kOhm.
## Parameters
2016-07-05 23:04:12 +02:00
2016-11-02 01:44:37 +01:00
* ``name``: The @boardname@ hardware pin to configure (``P0``-``P20``)
2016-07-19 00:51:28 +02:00
* ``pull``: The pull to which to set the pin (**down**, **up**, or **none**)
2016-07-05 23:04:12 +02:00
## Example
2016-07-05 23:04:12 +02:00
The following example sets the pull of pin ``P0`` to **up** (high).
```blocks
pins.setPull(DigitalPin.P0, PinPullMode.PullUp);
```
## See also
2016-07-05 23:04:12 +02:00
[@boardname@ | mbed](https://developer.mbed.org/platforms/Microbit/)