# 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>
