A voltage divider (also known as a potential divider) is a simple circuit that produces an output voltage (Vout) that is a fraction of its input/supply voltage (Vin or Vs). Basically voltage is divided according to the ratio of the resistors. It has many uses but a common one is converting a variable resistor like a photocell or flex sensor to a varying voltage that a microcontroller like the Arduino can read.
Here are some other ways of drawing the same circuit:
Using a potentiometer as a voltage divider
You can make a quick voltage divider with a potentiometer, since it has an extra pin to output a second resistance, so you essentially get two resistors in one component. One thing about doing this with a potentiometer that often confuses beginners is that you can use a pot in several different ways. First of, it has three pins instead of two like the little static resistors. That’s because there’s a wiper moving over a resistive semi-circle inside and a pin connected to both ends of that circle.
The total resistance of the potentiometer, that is between pin1 and pin3, is always the same. A 10k pot always means 10,000 ohms of resistance from end to end, no matter where you move the middle wiper. But measuring the resistance from one end to the wiper, you get a variable resistance.
In a potentiometer the resistances will always be inverse to each other. When you lower one (by turning a knob for example), the other side will go up. When you raise one, the other will go down. For example:
- If a 10k pot is turned to the exact middle, you’ll have 5K and 5k (=10k).
- If it’s turned to 30% (like in the diagram above), you’ll have 3K and 7k (=10k).
- If a 50k pot is turned 30%, you’ll get 15k and 35k (=50k).
There are many kinds of potentiometers out there, not just little knobs:
The simplest way to use a pot (short for potentiometer) is as a single resistor using only two of the three pins, that is, the middle pin (wiper) and your choice of one of the outer pins, i.e. one end of the resistive track. In these cases:
- Power input is connected to the middle pin, and flows through varying resistances to either pin.
- Power output (the same voltage as your power source) comes out of either side pin, only the amount of current changes as you vary the resistance (e.g. turn the knob).
Another way to use a pot is as taking advantage of getting two resistances in one component by hooking it up as a voltage divider. To do this, use all three pins to get the resistance between the middle pin (wiper) and one pin AND the resistance between the middle pin and the other pin. In the above illustration, that would be the resistance between pin2 and pin1, and between pin2 and pin3.
- Power input connected to one of the side pins (only one)
- Ground connected to the other side pin
- Varying voltage output coming out of the middle pin (wiper/slider).
Any voltage divider ratio is useful just as a ratio. This ratio will effect how the input voltage is divided, and thus for example, turning a knob will effect the output voltage. In this case, it doesn’t matter what the total resistance value of a potentiometer is, 10k, 1000K, whatever, when used as a voltage divider, it’s just a ratio. Let’s say the input voltage is +5V. If you turn the knob 30% of the way, you’ll get 30% of the input voltage, or 1.5V. With an Arduino you can read this varying voltage and do something fun with it, like light things up part-way, change the pitch of a musical tone, turn on fans in a room, move a robot arm, etc.
A potentiometer happens to have a third pin conveniently placed for you, so it’s an easy way to make your first voltage divider circuit. Most other variable resistors, like the photoresister (aka photocell) in your kit, only have two pins. So in those cases you need to add a second resistor yourself. More on that below.
Again, some Ohm’s Law: as a single resistor hooked up to a power source, the voltage cannot change, so as you change resistance, you are only affecting current (more resistance = less current). As a set of two resistors in a voltage divider circuit, you are affecting voltage. With an LED, either method can be used to dim and brighten it. With most other components you will need to effect only one or the other.
Understanding Voltage Dividers:
This video is good but goes very quickly through examples, use the pause button to look at the numbers and make sure you understand them. Note: the second half of the video is more advanced and not necessary now.
The math isn’t too bad, but here is a calculator if you hate math:
Using other variable resistors as a voltage divider
With a variable resistor like a photocell (light sensor) or FSR (pressure sensor), you’ve only got one resistor, so to make a voltage divider you have to provide the second resistor. How do you know what value to use? In practice something in the middle of the range of resistance you expect to get from your sensor will work. Kind of. If you need more sensitivity or resolution, you will want something more exact. You can find the ideal value by measuring the minimum and maximum resistance your sensor gives you in your application, and then using this formula to calculate the value of the fixed resistor:
R = √ ( Rmin * Rmax)
Let’s say I’m using a photocell and the darkest condition my piece will be in produces a resistance of 75k ohms, and the lightest condition 2k ohms. My ideal fixed resistor in a voltage divider circuit would be √150, or 12.25k. You don’t need to be exact, 10k is fine. With one fixed resistor you won’t get linear results (unlike a potentiometer with its always-balanced variables resistances). But real-world light and a cheap photocell is probably not linear anyway.
If the output is the inverse of what you want it to be (e.g. when it gets darker you want output LED to get brighter, but instead it gets dimmer), you can inverse your circuit – just swap the variable resistor (photocell) and fixed resistor. You could also invert the output by changing your code. Here’s more reading explaining this in more detail: https://learn.adafruit.com/photocells/using-a-photocell.
Here’s a comparison of voltage dividers with fixed resistors and different kinds of variable resistors. Note that the potentiometer symbol is yet another way to draw a variable resistor, in this case showing that you (the user) can adjust it up and down.