> For the complete documentation index, see [llms.txt](https://learn.breadstick.ca/breadstick/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.breadstick.ca/breadstick/pico-slices/slice-1-led-mixer/circuitpython-code/2-analog-read-to-plotter.md).

# 2 - Analog Read to Plotter

### Video

{% embed url="<https://youtu.be/4YrJU96EuUo>" %}

### Code with Detailed Comments

```python
'''
Pico Slice 1 - RGB Mixer
Tutorial 2 - Analog Read to Plotter
'''

# First we import the modules we're going to use in our code
import time
import board
from analogio import AnalogIn

# We'll represent the potentiometer in code as an AnalogIn object
# This makes it very easy to use the ADC to convert analog voltages to digital values
r_pot = AnalogIn(board.A2)

while True:                         # Loop Forever:
    analog_val = r_pot.value            # Read the analog value from r_pot's value attribute
    plotter_data = (analog_val,)        # The plotter expects Tuples (32,45,-21) and this is how we create 1 value tuple
    print(plotter_data)                 # Send tuple to the computer over USB, it'll automatically show up in the Serial and Chart 
    time.sleep(0.1)                     # Do nothing for 100 milliseconds
    
    print((r_pot.value,))               # Do the same thing as above, but in a single line of code
    time.sleep(0.1)  
```

### Just Code

```python
'''
Pico Slice 1 - RGB Mixer
Tutorial 2 - Analog Read to Plotter
'''

import time
import board
from analogio import AnalogIn

r_pot = AnalogIn(board.A2)

while True:                                    
    
    print((r_pot.value,))              
    time.sleep(0.1)  
```

### Additional Information

<https://codewith.mu/en/tutorials/1.1/plotter>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://learn.breadstick.ca/breadstick/pico-slices/slice-1-led-mixer/circuitpython-code/2-analog-read-to-plotter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
