pxt-calliope/docs/reference/pins/servo-set-pulse.md

26 lines
870 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Servo Set Pulse
2016-04-13 17:27:45 +02:00
Configures the pin [pin](/device/pins) (``P0``, ``P1`` or ``P2``) as an analog/PWM output if it isn't already, configures the period to be 20ms, and sets the pulse width, based on the value it is given.
2016-03-26 00:47:20 +01:00
```sig
pins.servoSetPulse(AnalogPin.P1, 1500)
```
### Parameters
2016-04-13 17:27:45 +02:00
* `name` - [String](/reference/types/string); the pin name ("P0", "P1", or "P2")
* `micros` - a [Number](/reference/types/number) representing the micro-seconds of the pulse width.
2016-03-26 00:47:20 +01:00
### Example
The following code sets the servo pulse to ``1000`` micro seconds.
```blocks
pins.servoSetPulse(AnalogPin.P0, 1000)
```
### See also
2016-04-13 17:27:45 +02:00
[BBC micro:bit pins](/device/pins), [on pin pressed](/reference/input/on-pin-pressed), [analog read pin](/reference/pins/analog-read-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
2016-03-26 00:47:20 +01:00