2016-03-26 00:47:20 +01:00
|
|
|
# Servo Set Pulse
|
|
|
|
|
2016-06-30 21:43:42 +02:00
|
|
|
Configure the specified pin as analog output, set the period to 20
|
|
|
|
ms, and set the pulse width to the specified value.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```sig
|
|
|
|
pins.servoSetPulse(AnalogPin.P1, 1500)
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* ``name``: a [string](/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
|
|
|
|
* ``micros``: a [number](/types/number) that specifies the analog period in microseconds.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-06-30 21:43:42 +02:00
|
|
|
The following code sets the servo pulse to `1000` microseconds.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```blocks
|
2019-12-02 05:58:26 +01:00
|
|
|
pins.servoSetPulse(AnalogPin.P0, 1000)
|
2016-03-26 00:47:20 +01:00
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-11-01 18:42:42 +01:00
|
|
|
[@boardname@ pins](/device/pins),
|
2016-06-30 21:43:42 +02:00
|
|
|
[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)
|
2019-12-02 05:58:26 +01:00
|
|
|
|
|
|
|
[Brief Guide to Servos](https://www.kitronik.co.uk/pdf/a-brief-guide-to-servos.pdf)
|
|
|
|
|