pxt-calliope/docs/reference/pins/analog-set-period.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

1003 B

Analog Set Period

Configure the period of Pulse Width Modulation (PWM) on the specified analog pin. Before you call this function, you should set the specified pin as analog.

pins.analogSetPeriod(AnalogPin.P0, 20000)

Parameters

  • name: a string that specifies the pin to configure (P0 through P4, or P10)
  • micros: a number that specifies the analog period in microseconds.

The following code first sets P0 to analog with analog write pin, and then sets the PWM period of P0 to 20,000 microseconds.

pins.analogWritePin(AnalogPin.P0, 512)
pins.analogSetPeriod(AnalogPin.P0, 20000)

See also

@boardname@ pins, on pin pressed, analog read pin, analog write pin, digital read pin, digital write pin