# Potentiometer

In this experiment we will show and test what a poteniometer is and we use it to find voltages when microcontroller reads LOW and HIGH state on his digital input pin.

We cover the following topics

Voltage divider

General description

A voltage divider is a simple circuit which turns a large voltage into a smaller one. Using just two series resistors and an input voltage, we can create an output voltage that is a fraction of the input. Voltage dividers are one of the most fundamental circuits in electronics.

We may see it drawn a few different ways,

but they are always the same circuit. In this subsection we will denote the resistor closest to the input voltage $V_{in}$ as $R1$, and the resistor closest to ground as $R2$. The voltage drop across $R2$ is called $V_{out}$, and that is the divided voltage our circuit exists to make.

Generally speaking, formula used to calculate $V_{out}$ takes a form
$$V_{out} = \frac{V_{in}R_{2}}{R_{1}+R_{2}}$$

Why it is useful?

Many sensors in the real world are simple resistive devices. A photocell is one of a such variable resistor, which produces a resistance proportional to the amount of light it senses: the more light we provide the lower resistance of photocell is.

It turns out voltage is really easy for microcontrollers (at least those with analog to digital converters, ADC’s) to measure. Things are not so simple with resistance. But, by adding another resistor to the resistive sensors, we can create a voltage divider. Thus instead of measure resistance, we can measure voltage.Once the output of the voltage divider is known, we can go back and calculate the resistance of the sensor.

Consider the following schema

where the symbol of resistor with two arrows pointing to it is a symbol of photoresistor. Taking the photoresistor with resistance between 0kO in the full light and about 10kΩ in the dark accompanied by 10kO resistor, we will get 0.0V when there is full light and 2.88V in the full dark. If accompanying resistor has 1kO, we will get 0.62V when there is full light and 4.86V in the full dark.

 R1 Voltage in full light dark 10kO 0.2 2.88 1kO 0.62 4.86

Potentiometer

A potentiometer is a three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as a variable resistor.

We can think of a potentiometer as a variable voltage divider. Images below show all the possible states of a potentiometer and voltage dividers corresponding to them (notice that in this case voltage input and ground doesn't matter, so we skipped this element in the picture as well as we reverse order of resistors which again doesn't matter -- after all, it's just a matter of the agreement, which one we will call $R1$ and wich one \$R2.)

Test idea

Take the Arduino board and make the following test

• Turn potentiometer to one of its final position.
• Use middle potentiometer's pin output signal as input signal for digital and analog Arduino's pins
• In Arduino
• read digital pin value and print HIGH if this pin is in HIGH state and LOW if is in LOW state
• read analog pin value and print voltage
• Change, not to fast, potentiometer position to oposite final position. Doing this, read and print digial and analog values (see previous step). Note when digital state will switch to HIGH when voltage is increased from 0V to 5V, and when digital state will switch to LOW when voltage is decreased from 5V to 0V.

Wiring

Code

Below tere is a code we can use to make this test.

Read an appropriate documentation if you don't know how function we used are working

Results

In my case

• when voltage is increased from 0V to 5V, digital state switches to HIGH for 2.7V
• when voltage is decreased from 5V to 0V, digital state switches to LOW for 2.16V.    Top-left: Step 1, initial voltage about 0V, LOW state; top-right: Step 2; bottom-left: Step 3; bottom-right: Step 4, voltage about 2.7, HIGH state
film.mov