2016-03-26 00:47:20 +01:00
|
|
|
# Analog Read Pin
|
|
|
|
|
2016-04-13 17:27:45 +02:00
|
|
|
Read the specified [pin](/device/pins) (P0, P1, P2) as analog.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```sig
|
|
|
|
pins.analogReadPin(AnalogPin.P0)
|
|
|
|
```
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
* name - the pin name (`P0`, `P1`, or `P2`)
|
|
|
|
|
|
|
|
### Returns
|
|
|
|
|
2016-04-13 17:27:45 +02:00
|
|
|
* [Number](/reference/types/number) - a number between 0 and 1023 (included)
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
The following code reads `P1` and charts it on the screen:
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
basic.forever(() => {
|
|
|
|
let value = pins.analogReadPin(AnalogPin.P1)
|
|
|
|
led.plotBarGraph(value, 1023)
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
### See also
|
|
|
|
|
2016-04-13 17:27:45 +02:00
|
|
|
[micro:bit pins](/device/pins), [on pin pressed](/reference/input/on-pin-pressed), [analog write pin](/reference/pins/analog-write-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
|
|
|
|