We want some way to control the location of the pixel using some form of input. For our knob sketcher, we will use a couple of pots. One to control left and right, and one to control up and down.

So what is a pot? A thing you put dirt and plants in? Or the thing you make soup in? Well, yes. But in electronics, it is short for potentiometer. So what is a potentiometer? It's a fancy word for a resistor with a variable value. How do you vary the value of this variable resistor? Easy - with a knob. Just grab it, turn it, change it.

Let's take a closer look.

## Pot Internals

 Let's start by looking at a normal resistor with a fixed value. These are super common and look something like the image below. The actual resistor is shown on the left and one way of representing it in drawings is shown on the right.

The color bands can be used to determine what the actual value of the resistors is. But that's not important for what we are doing here. Let's just call it R1.

 Now consider two resistors put together so they are connected together. Like this!

Now there are three leads as shown in the drawing on the right. Again, we are not concerned about the actual value of the second resistor, so we are just calling it R2.

 This is basically what the inside of a potentiometer has. So those two resistors become our pot. And to better illustrate what the three tabs are doing.

But where is the variability? Are R1 and R2 fixed values and that's all there is to it? No. The way a pot works is you can change the values of R1 and R2 by turning the knob. They don't change separately. The total resistance obtained by adding R1 and R2 together will always be the same - the overall value for the pot.

The pot shown above is a fairly common 10k pot. That means its total resistance is 10,000 ohms. So:

The knob will change the values of R1 and R2, anywhere from 0 up to 10000. But the above relation will always hold. For this style pot (linear), the variation would look something like this:

If you just wanted to use a pot as a single variable resistor, you could. You would just use the middle connector and only one of the outer connectors. Then you would have a resistor that would vary from 0 to 10000 as the knob is turned.

However, we are going to use all three pins in an arrangement known as a voltage divider. So let's look at that in a little more detail.

## Variable Voltage Divider

 Here is how to wire up the pot to create a voltage divider.

You could use Ohm's Law on this to figure out how it works, but we'll just give you the answer. Here it is:

In our case, we will have Vin be a constant value (3.3V). As we turn the knob on the pot, we will change R1 and R2 as described previously and therefore get a varying Vout. Consider the limiting cases of turning the knob all the way in either direction.

All the way in one direction (not the boy band!) will produce R1 = 0, R2 = 10000. The fraction then becomes 1 and we get Vout = Vin.

All the way in the other direction (is that a boy band?) will produce R1 = 10000, R2 = 0. The fraction then becomes 0 and we get Vout = 0.

Knob positions in between these two limits will produce different values, and so will "divide" the input voltage down to some value.

The result looks something like this:

Let's wire this up and see it in action.

## Try It Yourself

The variable voltage divider setup is shown below. Vin (red wire) is wired to 3.3V (3V) and Vout (yellow wire) is wired to one of the analog inputs (A0) so we can measure the resulting voltage. The other wire (black wire) goes to GND (G).

Here is a short CircuitPython program that simply reads the analog input value over and over in a loop and prints it out.

```import time
import board