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

891 B

Analog Write Pin

Write an analog signal (0 through 1023) to the pin you say.

pins.analogWritePin(AnalogPin.P0, 400)

Parameters

  • name is a string that is the pin name you say (P0 through P4, or P10)
  • value is a number from 0 through 1023

Example

This program writes 1023 to pin P0.

pins.analogWritePin(AnalogPin.P0, 1023)

~hint

When you tell it to write 256 (for example), this function does not really write 256. Instead, it writes a lot of different numbers, and their average is 256.

~

See also

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