← Projects
electronics intermediate Jul 15, 2026 ◯ 8 min read

Build a Variable Bench Power Supply: LM317, Current Limiting, LED Drivers, and Upgrades

Build time: 1 day
Tools needed: Soldering iron, multimeter
Parts List

Project Overview

Every electronics workbench needs a variable power supply. This project starts with a simple but capable LM317-based adjustable supply and builds up through multiple upgrade stages — adding digital voltage/current display, constant-current LED driving, USB output, and lithium battery charging. By the end you'll have a versatile bench tool that can power circuits from 1.25V to 30V, drive LED strips, charge batteries, and provide clean 5V USB power — all built from widely available components for under $40.

Stage 1: Basic LM317 Adjustable Supply

The LM317 is the classic adjustable voltage regulator — three pins, two resistors, and you have a stable adjustable output from 1.25V up to about 2V below your input voltage.

How the LM317 Works

The LM317 maintains exactly 1.25V between its OUTPUT and ADJ pins. By connecting a resistor divider from OUTPUT to ADJ to GND, you set the output voltage:

Vout = 1.25V × (1 + (R2 / R1))

Where R1 is between 100Ω and 240Ω (typically 240Ω) and R2 is your adjustment resistor. A potentiometer for R2 lets you vary the output voltage.

Parts List - Stage 1

ComponentValuePrice LM317T (TO-220)1.5A adjustable regulator$0.30 Transformer (or wall adapter)12-24V AC or DC, 1-2A$5-15 Bridge rectifier (if using AC input)2A, 50V$0.50 Filter capacitor2200μF 35V electrolytic$1.00 R1240Ω 1/4W$0.01 R2 (potentiometer)5kΩ linear$1.00 Cin0.1μF ceramic$0.05 Cout10μF 25V electrolytic$0.10 Protection diode D11N4007$0.05 Protection diode D21N4007$0.05 HeatsinkTO-220 compatible$1.00 Banana jacks or terminal blocksRed + Black pair$2.00 EnclosureProject box 100×60×40mm$3.00 Stage 1 Total$14-24

Circuit Diagram - Stage 1

Input (+) → Bridge Rectifier → 2200μF Cap (+) → LM317 Vin | 2200μF Cap (-) → GND LM317 Vout → R1 (240Ω) → ADJ pin (feedback loop) | → R2 (5k pot) → GND | → Cout (10μF) → GND | → Output (+) GND → Output (-) Protection diodes: D1: Vin → Vout (reverse protection if input shorted) D2: ADJ → Vout (protects if ADJ pin current exceeds safe limit)

Assembly Steps

  1. Mount the LM317 on the heatsink with thermal compound and insulating washer (if heatsink is not isolated)
  2. Install the bridge rectifier and filter capacitor on a perfboard or breadboard
  3. Wire R1 (240Ω) between LM317 Vout and ADJ pins — solder directly or use short wires
  4. Wire the 5kΩ potentiometer: one end to ADJ, wiper to the other end to GND
  5. Install Cout (10μF) close to the LM317 output pins
  6. Install protection diodes D1 (anode to Vout, cathode to Vin) and D2 (anode to ADJ, cathode to Vout)
  7. Connect Cin (0.1μF) between Vin and GND, close to LM317
  8. Mount banana jacks or terminal blocks for output
  9. Test: power on, adjust potentiometer, verify output varies from ~1.25V to ~Vinput - 2V

Heat Dissipation

Power dissipated in LM317 = (Vin - Vout) × Iload Example: Vin = 15V, Vout = 5V, Iload = 0.5A P = (15-5) × 0.5 = 5W — requires substantial heatsink

The LM317 has thermal shutdown at ~125°C junction, but sustained high dissipation reduces lifespan. For loads over 500mA with large Vin-Vout differentials, use a larger heatsink or consider a switching regulator.

LM317 Specifications

ParameterValue Input voltage range3V to 40V Output voltage range1.25V to 37V Maximum output current1.5A (with adequate heatsinking) Line regulation0.01%/V typical Load regulation0.1% typical Reference voltage (Vref)1.25V (between OUT and ADJ) Minimum load current3.5mA (R1 = 240Ω gives 5.2mA, which is sufficient)

Stage 2: Add Current Limiting

A basic LM317 supply has no current limiting beyond its internal protection. Adding an external current limit prevents damage to circuits under test.

Simple Current Limiter (BJT + Resistor)

Add a PNP transistor (2N2907) and sense resistor: Sense resistor (Rsc): 0.68Ω 2W between LM317 output and actual output terminal PNP emitter → actual output terminal PNP base → LM317 output (before sense resistor) PNP collector → GND (or ADJ pin for foldback limiting) When current × Rsc exceeds ~0.6V, the PNP turns on and shunts current away, limiting output current to approximately: Ilimit = 0.6V / Rsc With Rsc = 0.68Ω: Ilimit = 0.6/0.68 = 0.88A (practical limit)

LM317 as Constant-Current Source

Interestingly, the LM317 can also work as a constant-current driver — perfect for LEDs:

Connect LM317: Vin → Vin pin, Vout pin → LED anode, ADJ pin → LED cathode → Rset → GND The LM317 maintains 1.25V across Rset, so: Iout = 1.25V / Rset For 350mA LED drive: Rset = 1.25/0.35 = 3.57Ω → use 3.3Ω (gives ~380mA) Power in resistor: P = 1.25 × 0.35 = 0.44W → use 1W resistor

This configuration drives any number of series LEDs (up to Vin - 3V) at a constant current, regardless of input voltage variations or LED forward voltage differences.

Stage 3: Digital Voltmeter/Ammeter Display

Add a cheap digital panel meter to monitor voltage and current in real-time.

Parts

ComponentPrice 0-100V 0-10A digital voltmeter/ammeter (panel mount)$4-8 Shunt resistor (included with meter, usually 0.01Ω 10W)included Small switch for meter power (optional)$0.50

Wiring the Meter

  1. Voltage sense: Thin red wire to supply positive (or output after current shunt), thin black wire to ground
  2. Current sense: Thick red wire to supply positive input, thick black wire to load — the shunt sits in series with the load
  3. Meter power: Connect to 5-30V DC (can tap from your input or use a separate 78L05 regulator)
  4. Calibrate by comparing with a known-good multimeter

Stage 4: Add USB 5V Output

A dedicated 5V USB port lets you power and charge phones, Arduino boards, and Raspberry Pis directly.

Option A: Linear (7805-based, simple, runs warm)

LM317/rectifier output → 7805 Vin 7805 Vout → USB-A female connector (VCC = pin 1, GND = pin 4) Add 0.1μF and 10μF caps on both input and output of 7805 Add LED with 1kΩ resistor to show USB power on

Good for low-current USB devices (under 500mA). The 7805 burns excess voltage as heat.

Option B: Switching Buck Module (efficient, cooler)

LM317/rectifier output → XL4015 or LM2596 buck module set to 5.2V Buck output → USB-A connector with data lines shorted (2-3) for 1A charge signaling Add 1000μF cap on output for USB spec compliance

Much more efficient — 90%+ vs 30-50% for linear. Can deliver 2-3A continuously without excessive heat. Buck modules cost $2-3 on Amazon/eBay.

Stage 5: Lithium Battery Charger

Add a TP4056 module for charging 18650 lithium cells safely:

ComponentPrice TP4056 charging module (micro-USB input)$0.50-1.00 18650 battery holder$0.50 18650 cell (LG HG2, Samsung 30Q, or similar)$4-8 Protection module (DW01A + FS8205A)$0.30

Wiring

  1. TP4056 input (micro-USB or pads): connect to your rectified DC input (5-8V optimal)
  2. TP4056 B+/B- outputs: connect through protection module to 18650 holder
  3. Protection module output: becomes your battery terminals
  4. Add a boost converter (XL6009 or MT3608) to step battery voltage up to 5V or 12V as needed

Stage 6: Putting It All Together

Suggested Front Panel Layout

[USB 5V] [Banana Jacks: Red + / Black -] [5mm Binding Posts] | | | [USB LED] [Digital Meter: XX.XXV X.XXXA] [On/Off Switch] | | | [USB Current] [Voltage Adjustment Knob] [Current Limit Knob] | | | [Charge LED] [Fine/Coarse Switch (optional)] [Mode: CV/CC LED]

Wiring Diagram - Complete System

AC Input / Wall Adapter → Fuse → Power Switch → Bridge Rectifier | 2200μF Filter Cap | +---------+---------+ | | LM317 Supply XL4015 Buck Module (1.25V-Vin-2V) | | 5.2V USB Output Current Shunt | | TP4056 Charger Output Terminals | | 18650 Battery Digital Meter | | MT3608 Boost (optional) | | Load/Work circuit 5V/12V Aux Output

Upgrades and Variations

LM338 (5A Version)

Drop-in replacement for LM317 with 5A output capability. Same pinout, same circuit, just more current. Requires much larger heatsink ($5-10).

LT3080 (Low Dropout, Parallelable)

1.1A LDO with 350mV dropout. Can be paralleled for more current. Excellent line and load regulation. $3-5.

Switching Buck Module as Main Supply (High Efficiency)

For higher current with less heat, replace the LM317 with an adjustable buck module:

Dual Tracking Supply (+/- voltage)

For op-amp circuits and audio:

Safety Considerations

Bill of Materials - Complete Build

ItemQtyTotal LM317T + heatsink1$1.30 12V 2A wall adapter (safer than transformer)1$8.00 Bridge rectifier + filter cap1$1.50 Resistors, caps, diodes, potentiometerset$2.00 Digital voltmeter/ammeter1$6.00 XL4015 buck module (USB 5V)1$3.00 TP4056 charger + 18650 holder1$2.00 Banana jacks, USB-A connector, switch, LEDset$4.00 Enclosure 120×80×50mm1$4.00 Perfboard1$1.00 Wire, solder, connectors$2.00 Grand Total$34.80

Troubleshooting

ProblemCauseFix No outputLM317 pinout wrong; no input voltage; blown fuseVerify pinout (ADJ, Vout, Vin from front); check fuse; measure input Output stuck at ~1.25VR2 open circuit; potentiometer broken or miswiredCheck R2 continuity; verify pot wired correctly Output varies with loadInadequate input capacitance; LM317 oscillatingAdd 10μF tantalum at input; add 0.1μF ceramic close to pins LM317 gets extremely hotExcessive power dissipationReduce input voltage; add bigger heatsink; reduce load current Output has AC rippleInsufficient filter capacitanceIncrease filter cap to 4700μF or more; add 100nF ceramic Current limit not workingSense resistor too large or small; transistor wrong typeVerify Rsc value; check PNP orientation; test transistor Meter reads wrongMeter powered from output being measured (loading effect)Power meter separately or from pre-regulator voltage USB output not charging phoneNo D+/D- short; insufficient current; voltage too lowShort USB data pins (2-3); ensure 5V at load; check wiring