2016-03-26 00:47:20 +01:00
|
|
|
# Analog Write Pin
|
|
|
|
|
2016-06-29 22:10:45 +02:00
|
|
|
Write an **analog** signal (`0` through `1023`) to the
|
|
|
|
[pin](/device/pins) you say.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```sig
|
2016-11-10 22:08:45 +01:00
|
|
|
pins.analogWritePin(AnalogPin.P1, 400)
|
2016-03-26 00:47:20 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
2016-07-19 00:51:28 +02:00
|
|
|
* ``name`` is a [string](/reference/types/string) that is the pin name you say (`P0` through `P4`, or `P10`)
|
|
|
|
* ``value`` is a [number](/reference/types/number) from `0` through `1023`
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-06-29 22:10:45 +02:00
|
|
|
### Example
|
|
|
|
|
|
|
|
This program writes `1023` to pin `P0`.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```blocks
|
2016-11-10 22:08:45 +01:00
|
|
|
pins.analogWritePin(AnalogPin.P1, 1023)
|
2016-03-26 00:47:20 +01:00
|
|
|
```
|
|
|
|
|
2016-06-29 22:10:45 +02:00
|
|
|
#### ~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`.
|
|
|
|
|
|
|
|
#### ~
|
|
|
|
|
2016-03-26 00:47:20 +01:00
|
|
|
### See also
|
|
|
|
|
2016-11-02 01:44:37 +01:00
|
|
|
[@boardname@ 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)
|
2016-03-26 00:47:20 +01:00
|
|
|
|