Edited advanced topic
This commit is contained in:
parent
92c63b615a
commit
36e6570296
@ -1,6 +1,7 @@
|
|||||||
# Servo Set Pulse
|
# Servo Set Pulse
|
||||||
|
|
||||||
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.
|
Configure the specified pin as analog output, set the period to 20
|
||||||
|
ms, and set the pulse width to the specified value.
|
||||||
|
|
||||||
```sig
|
```sig
|
||||||
pins.servoSetPulse(AnalogPin.P1, 1500)
|
pins.servoSetPulse(AnalogPin.P1, 1500)
|
||||||
@ -8,12 +9,12 @@ pins.servoSetPulse(AnalogPin.P1, 1500)
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
* `name` - [String](/reference/types/string); the pin name ("P0", "P1", or "P2")
|
* `pin`: a [string](/reference/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
|
||||||
* `micros` - a [Number](/reference/types/number) representing the micro-seconds of the pulse width.
|
* `μs`: a [number](/reference/types/number) that specifies the analog period in microseconds.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
The following code sets the servo pulse to ``1000`` micro seconds.
|
The following code sets the servo pulse to `1000` microseconds.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
pins.servoSetPulse(AnalogPin.P0, 1000)
|
pins.servoSetPulse(AnalogPin.P0, 1000)
|
||||||
@ -21,5 +22,8 @@ pins.servoSetPulse(AnalogPin.P0, 1000)
|
|||||||
|
|
||||||
### See also
|
### See also
|
||||||
|
|
||||||
[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)
|
[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)
|
||||||
|
Loading…
Reference in New Issue
Block a user