For years, I tested every circuit the same annoying way: dig through a drawer of mismatched wall adapters, hope one of them was close enough to the voltage I needed, and use alligator clips to make it work. Then I finally built a proper adjustable bench power supply using an LM317 regulator, and it's honestly one of those tools that instantly makes every future project easier. Turn a dial, get exactly the voltage you need, from about 1.25V up to 30V depending on your input supply. No more drawer archaeology.
This guide walks through building your own LM317-based adjustable power supply from scratch — the circuit, the math behind it, and the mistakes worth avoiding.
Why the LM317 Specifically
The LM317 is a linear voltage regulator that's been a hobbyist staple for decades, and for good reason. It's cheap, incredibly forgiving to work with, and needs only two external resistors to set your output voltage — swap one of those resistors for a potentiometer, and you've got an adjustable supply instead of a fixed one. It's not the most efficient regulator design out there (linear regulators waste energy as heat rather than converting it efficiently like switching regulators do), but for a bench supply used at moderate currents, that trade-off is well worth the simplicity.
What You'll Need
- 1x LM317 voltage regulator (in a TO-220 package — the one with the metal tab, which you'll want for heat dissipation)
- 1x 240Ω resistor (this is the standard fixed resistor value for LM317 circuits — sometimes labeled R1)
- 1x 5k potentiometer (this becomes your adjustable resistor — sometimes labeled R2 — and directly determines your voltage range)
- 2x 100nF ceramic capacitors (for stability, especially important if your input supply has any long wire runs)
- 1x 1µF and 1x 10µF electrolytic capacitor (for filtering ripple on the input and smoothing the output)
- 1x small heatsink for the LM317 (don't skip this — more on why below)
- A DC input source higher than your desired maximum output (a simple transformer, bridge rectifier, and filter capacitor setup, or a wall adapter rated around 24-30V DC works well)
- A multimeter, for calibration and general sanity-checking as you build
The Math Behind the Circuit (Don't Worry, It's Simple)
The LM317 works by maintaining a constant 1.25V reference between its output pin and its adjustment pin. That fixed reference, combined with your two resistors, is what determines the actual output voltage, using this formula:
Vout = 1.25 × (1 + R2/R1)
With R1 fixed at 240Ω, swapping in a 5k potentiometer for R2 gives you a usable range from about 1.25V (potentiometer at zero) up to roughly 27V (potentiometer at full resistance), assuming your input supply can actually provide that much headroom.
You genuinely don't need to memorize this formula to build the circuit, but understanding it makes troubleshooting a lot more intuitive — if your voltage seems locked at a particular ceiling, it's very often because your input supply itself can't provide any more, not because something's wrong with your wiring.
Understanding the Wiring
- LM317 Pin 1 (Adjust) → connects to one end of your potentiometer, and also to the junction between the two resistors
- LM317 Pin 2 (Output) → your positive output terminal, also connects through R2 (the potentiometer) back to Pin 1
- LM317 Pin 3 (Input) → your unregulated DC input voltage
- R1 (240Ω) connects between Pin 1 and ground
- The 100nF ceramic capacitors go across the input and output pins to ground, close to the chip itself, for stability
- The 1µF capacitor sits on the input side, and the 10µF capacitor on the output side, both helping smooth out any ripple
Circuit Diagram
(See the schematic below — an LM317 regulator with its Adjust pin connected between a fixed 240Ω resistor to ground and a 5k potentiometer wiper feeding back from the output, forming the classic adjustable voltage divider configuration, with stability capacitors placed close to the input and output pins.)
Building It on a Breadboard First
Before soldering anything permanently, breadboard the whole circuit and test it thoroughly. Connect your multimeter across the output terminals, apply power, and slowly turn the potentiometer through its full range while watching the voltage change smoothly. It should track predictably from low to high with no jumps or dead zones.
If you're planning to actually use this as a working bench supply rather than just a one-off experiment, this is also the point to add a voltage display — a cheap digital voltmeter module wired across the output saves you from needing a separate multimeter every time you use it, and it's a genuinely worthwhile upgrade.
Don't Skip the Heatsink
Here's the thing about linear regulators like the LM317: the difference between your input voltage and output voltage gets dissipated as heat, proportional to the current being drawn. If you're stepping down from 24V input to a 5V output while drawing even a modest 500mA, that's nearly 10 watts being burned off as heat directly on the chip. Without a heatsink, the LM317 will overheat and trigger its internal thermal shutdown protection — which isn't dangerous, but it does mean your "power supply" will just mysteriously stop working under load, which is a confusing thing to debug if you don't know to look for it. A small clip-on heatsink solves this completely for most hobbyist-level current draws.
Common Problems (And How I Actually Fixed Them)
The output voltage won't go above a certain point, no matter how far I turn the potentiometer. Check your input voltage first — the LM317 needs roughly 2-3V of headroom above whatever output you're trying to achieve. If you want a 20V output, your input supply needs to be comfortably above that, not right at the edge.
The output voltage is unstable or drifts when I connect a load. This is almost always a missing or poorly placed stability capacitor. Make sure your 100nF ceramic capacitors are physically close to the LM317's pins, not dangling at the far end of long breadboard wires.
The chip gets hot and the output voltage drops under load. This is the thermal shutdown behavior mentioned above. Add a heatsink, and if it's still an issue at higher currents, consider a larger heatsink or reducing the voltage difference between input and output where possible.
The voltage reading seems to jump around slightly rather than staying rock steady. A cheap or worn potentiometer can introduce noise as the wiper moves across the resistive track. This is usually more noticeable during adjustment and settles once you land on a value — if it persists even when untouched, consider a higher-quality potentiometer.
Taking It Further
Once the basic circuit works, a few upgrades are genuinely worth the extra effort: adding a current-limiting circuit (protects both your project and the supply itself from accidental short circuits), building it into a proper enclosure with binding posts for output connections, or adding a second LM317 stage for a dual-rail supply if you regularly work with op-amp circuits that need both positive and negative voltage rails.
Final Thoughts
This is one of those foundational circuits that pays for itself the very first time you use it. Every future project on this blog — the sensor builds, the relay circuits, all of it — becomes easier to test and debug once you can dial in exactly the voltage you need instead of guessing with whatever wall adapter happens to be closest. If you're serious about building more electronics projects going forward, this is honestly one of the best first investments of your time, before even your next microcontroller project.



