789 B
789 B
Analog Read Pin
Read the specified pin (P0, P1, P2) as analog.
pins.analogReadPin(AnalogPin.P0)
Parameters
- name - the pin name (
P0
,P1
, orP2
)
Returns
- Number - a number between 0 and 1023 (included)
The following code reads P1
and charts it on the screen:
basic.forever(() => {
let value = pins.analogReadPin(AnalogPin.P1)
led.plotBarGraph(value, 1023)
});
See also
micro:bit pins, on pin pressed, analog write pin, digital read pin, digital write pin