pxt-calliope/docs/examples/plot-analog-pin.md

19 lines
386 B
Markdown
Raw Normal View History

2017-02-10 02:40:21 +01:00
# Plot Analog Pin
Use this program to graph the analog value on pin ``P0``, ``P1`` or ``P2``.
Press ``A`` to scroll the value on the screen.
2017-02-10 02:40:21 +01:00
```blocks
let reading = 0
2017-02-10 02:40:21 +01:00
basic.forever(() => {
reading = pins.analogReadPin(AnalogPin.P0)
2017-02-10 02:40:21 +01:00
led.plotBarGraph(
reading,
2017-02-10 02:40:21 +01:00
1023
)
if (input.buttonIsPressed(Button.A)) {
basic.showNumber(reading)
}
2017-02-10 02:40:21 +01:00
})
```