Learn
Regulating Voltage with a DC-DC Buck Converter (LM2596) on a Raspberry Pi 4B
Wire an adjustable LM2596 buck converter between a DC power source and a load, set its output voltage and current rating in the settings panel, and see it clamp, regulate, and current-limit for real — three real-world presets: 5V/5A, 4V/5A, and 5V/2A.
Note: the DC-DC Buck Converter (LM2596) is a Premium-tier component in the simulator — you’ll need a Premium or VIP plan to use it there.
Try this directly in the free Raspberry Pi 4B simulator — no hardware or signup required. New to the GPIO header? Start with the interactive pinout guide.
What you’ll need
- Raspberry Pi 4B
- DC-DC Buck Converter (LM2596)
- DC Power Supply (a simple adjustable-voltage source to feed the converter's input)
- Resistor (~220Ω)
- LED
Step by step
- Drag Raspberry Pi 4B, DC Power Supply, DC-DC Buck Converter (LM2596), a Resistor, and an LED onto the Canvas.
- Hover over the buck converter's 4 pins to confirm the labels: IN+, IN−, OUT+, OUT−.
- Wire the input side: DC Power Supply's + → the converter's IN+. DC Power Supply's − → the converter's IN−.
- Wire the output side into a simple load, the same way you'd wire any regulated power source: converter's OUT+ → a Resistor → the LED's anode. LED's cathode → the converter's OUT−. Wire the converter's OUT− → a Pi GND pin too, so the whole circuit shares one common ground.
- Click the DC Power Supply to select it and set its output — try 12V, a realistic real-world input for this kind of module.
- Click the buck converter to select it, open its settings panel, and try the first preset: 5V / 5A. This is what a real LM2596 module set for a standard 5V rail looks like.
- Click Start — no Python code is needed for this circuit, since the LED is lit entirely by real wiring, the same zero-code behavior a Pi power pin already has.
The LED lights at full brightness. The converter's own on-canvas readout shows the real regulated output — 5.00V, unaffected by the 12V input, because a buck converter always steps voltage DOWN toward its own set point, never up and never past its input.
- Click Stop, reselect the converter, and switch its setting to the second preset: 4V / 5A. Click Start again — the LED is dimmer now (still lit, just less brightly, following the same resistor-aware brightness this simulator already applies to every LED), and the readout shows 4.00V.
- Click Stop, switch to the third preset: 5V / 2A, and set the DC Power Supply down to 3V (lower than the converter's own 5V set point). Click Start again.
Check the Console — you should see a warning that the output has been clamped to the input voltage. This is a real, physical fact about a buck converter: it can only step voltage DOWN, never up. With only 3V coming in, it cannot produce 5V no matter how it's set — the readout shows 3.00V, not 5.00V, and the warning explains why.
- Click Stop, set the DC Power Supply back to 12V, and click Start one more time to confirm the readout returns to a clean 5.00V with no warning.
What “working correctly” looks like
- Output voltage always matches the settings-panel value, UNLESS the input voltage is lower — in that case the output is clamped to whatever the input actually is, and the Console logs a warning explaining the clamp.
- Changing the DC Power Supply's own voltage never raises the buck converter's output past its own set point — only ever down toward it, or exactly at it once the input is high enough.
- A wired load that would draw more current than the Rated Current setting causes the output voltage to sag below the set point — a real "constant-current" foldback, not a hard cutoff — and the Console logs a warning naming both the demanded current and the rating.
- With no load wired at all (OUT+ genuinely unconnected to anything with a path back to OUT−), the converter still reports its own regulated voltage — a real buck converter regulates whether or not something is drawing power.
- A dead short (OUT+ wired directly to OUT− or GND with nothing else in between) folds the output all the way to 0V, not a crash or an error.
If something’s wrong
- Output always reads 0V → confirm IN− is genuinely wired back to a real ground (the DC Power Supply's − pin, ultimately reaching a Pi GND pin somewhere in the circuit) — the converter needs a real return path before it will regulate anything, the same as any other powered module in this simulator.
- Output matches the input exactly instead of the settings-panel value → double-check you're reading the converter's OWN readout, not the DC Power Supply's — and confirm Start was clicked again after changing the settings panel, since a change only takes effect on the next run.
- LED never lights even though the readout shows a real voltage → check the LED's anode/cathode orientation, and confirm OUT− is wired back to the same ground the LED's cathode side ultimately reaches — a floating return path on the load side breaks the circuit even if OUT+ itself is correctly wired.
- Expecting the output to rise above the settings-panel value when the input is very high → that's the one thing a buck converter can never do, by design — it only ever steps voltage DOWN. Raising the input above the set point does nothing once it's already above it; the output stays pinned at the set point.