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

870 B

Servo Set Pulse

Configures the pin pin (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.

pins.servoSetPulse(AnalogPin.P1, 1500)

Parameters

  • name - String; the pin name ("P0", "P1", or "P2")
  • micros - a Number representing the micro-seconds of the pulse width.

Example

The following code sets the servo pulse to 1000 micro seconds.

pins.servoSetPulse(AnalogPin.P0, 1000)

See also

BBC micro:bit pins, on pin pressed, analog read pin, digital read pin, digital write pin