DIP switch adjusted voltage regulator


It couldn’t be simpler but you have to admit that a small adjustable portable power supply like this one will be really handy.

The main part of the PSU is an LM317 linear voltage regulator which we’re already familiar with. The output voltage is adjustable based on a voltage divider between two of the pins. The set of eight DIP switches allows you to tweak that voltage divider. Switch number one connects the 9-volt battery connector to the regulator, serving as a power switch. Each of the other seven switches adjusts the output voltage by 1.5 volts. The output of the regulator connects to your target device using alligator clips which are not in frame above.

[Jason] says he takes this with him when thrift store hunting for cheap electronics. It can mimic most combinations of Alkaline cells letting you power up electronic toys to ensure they work. But we would find it equally useful for getting that early prototype away from the bench supply for testing before finalizing a dedicated portable supply.


  1. Mystick says:

    Simple… elegant.

  2. jshroomy says:

    I like this a lot… But where’s the Arduino?
    jk :)

  3. binary says:

    or use less dip and resistors like (270ohm x dip position) to get binary code for voltage.. :)

  4. Ripper121 says:

    “Turing on switch 1 turns on the circuit and brings the output up to 1.25V” and not “Each of the other seven switches adjusts the output voltage by 1.5 volts.”

    • cde says:

      It’s both. Switch 1 is the power switch. With all of the dip switches closed, the adjust pin is tied to ground, so it’s at 1.25v. Each switch opened at that point will increase the voltage by 1.5v. (1m36s in the video)

    • Nova says:

      Those are some very crude steps.. so you get 1.25, 2.75, 4.25, 5.75, 7.25, 8.75? that makes it nearly useless for most things. Why not 1.5v 1.8v 2.5v 3.3v 4v 5v?

      • Nearly useless for what things? I have a couple of 3.3v wall-warts, but I have no idea what they came from and I’ve never actually owned anything which runs on 3.3v external power.

      • michael says:

        can i tell you a secret……..most common rechargeable batteries(AAA,AA,C,D) are actually 1.25v, and not the ‘standard’ 1.5v……yet they have no problem running standard electronics.

        99% of consumer electronics actually fairly electrically ‘imprecise’…….because honestly, they dont need to be.

        if something will run at 3v….there is a good chance its also going to run fine anywhere from 2.75-3.25V

      • password says:

        Yo do realize yo can use any resistors you want to get any increment you want?

  5. TacticalNinja says:

    You can also solder the resistors laying flat and use a slide switch to make it even thinner. And while using a slide switch, the resistor array must have incrementing resistance as well to accommodate the slider switch. I’m making one later on.

  6. Haku says:

    Great idea but DIP switch seems too fiddly – next version with a rotary switch ?

  7. DainBramage1991 says:

    I’ve done something similar using a potentiometer instead of the dip switches/resistors. However, this is elegant, simple, effective, and you don’t need a meter to tell you what the output voltage is.
    I like it.

  8. strider_mt2k says:

    Great idea and well done!

  9. R-B says:

    He used the first position dip switch as power on switch. I wonder how much current this type of dip switch can handle as they are primarily made for logic input.

  10. Philip Strong says:
  11. maxmeazle says:

    a ha! we’ve found you at last Philip Strong! PRISM is pointing you now! XD

    The Happy NSA Surveillance Team

    P.S. This DIP switch hack is very cool!

  12. Wut? says:

    I have always implemented small variable voltage supplies like this by simply using a multiturn variable resistor….. Remember kids: You must put a load on the LM317 series in order to read the “operating voltage” …. If you leave the outputs floating, then the output voltage can vary wildly. This caused me all kinds of headache trying to figure out why my 317 supplies produced wildly different voltages from what I expected to see…..

  13. MS3FGX says:

    Bringing this to thrift shops is an excellent idea.

  14. Joe says:

    Very nice. Great Job!

  15. IndianTinker says:

    Great! I made it even smaller and breadboard-able!
    Check this out:


  16. Edward says:

    Headers and DIP jumbers would be less likely to accidentally change if you brush against the DIP switch.

  17. BotherSaidPooh says:

    I made a variant of this for laser diode testing, works well BUT needs output restriction via Zener diodes to stop the laser eating itself.

  18. Augur says:

    Could you wire in another 9v battery to get an adjustable voltage up to 18v?

    How would you wire in a switch to have two banks of batteries? (I.e. When the first 9v is depleted you could flip switch to second 9v). I’m asking because this could come in handy in so many ways.

    • mjrippe says:

      You can put a second 9v in series and the switches will give you 10.25, 11.75, 13.25, etc. The LM317 will actually go up to 30v this way. You can do higher voltages as well as long as the *difference* between input and output is not over 30v.

      A simple DPDT switch can swap two banks of batteries.

  19. Franklin Templeton says:

    Meant to comment on this yesterday but forgot to hit submit, the most important part lol. Love this! It is a simple circuit, can be used for a variety of applications, and is a good one for teaching soldering, troubleshooting, and board layout skills. Nice :) Already built a couple (Thanks to Jameco sending me 8000 dip switches in a grab bag order lol). I added a simple multi-barrel tip from an old wall wart multiadapter and can accommodate a variety of sizes and polarity swap on the fly :) Fun project!

  20. axodus says:

    i’m looking to control a power supply with pwm, what is the best way to do so?

    • Caleb says:

      Can you be more specific?
      Do you want to control the voltage output from a simple linear voltage drop regulator like the LM317 using the PWM from an arduino?
      Do you want to build a boost/buck power supply from scratch using only discreet chips?

      • axodus says:

        i thought about pwm the LM317, like here:

        but wonder: a)does it work b)is this the most efficient way to do so?

        • Caleb says:

          If your looking for efficiency go with a buck power supply. Or better yet a boost power supply and less batteries. Check out the minty boost for a simple example.

          That circuit doesn’t directly control the LM317 using a PWM signal. It uses the 47K resistor and 0.1uF C1 to convert the PWM into a voltage, like a simple DAC. The Opamp buffers and scales that voltage to set the reference voltage of the LM317.

  21. HackJack says:

    I have to admit. I suck at electronics.

    Now can someone tell me if a voltage regulator above save energy or not? If a 9V battery has 500mAh rating. And it is using the voltage regulator to output at 3V, what would the power rating be?

    • Caleb says:

      A simple formula to find efficiency of a LM317 is Efficiency = 100%-(Vin-Vout)/Vin. This ignores the power being used by the LM317.

      So your example of a 9V in and 3V out gives 33.3% effiency because 1-(9-3)/9=.333

      Your 9V battery with a 500mAh capacity would give 3V with 500mAh using this circuit with no losses in an ideal world ignoring all current going through the resistors and at a perfect discharge of your 9V.

    • Hans says:

      The difference in voltage is wasted. If you put 9 Volt in, and get 3 Volt out, the LM317 drops 6 Volt. If the current is 1 Ampere, that means that 6 Watt is turned into heat (power = voltage * current).
      This means that the total power use is always the same, it is the voltage going in * the current. If you turn down the output voltage, it just means that a bigger part of it ends up in the heat sink.
      To get the power rating at 3V, you need to look up the data sheet. There you will read “Output-Current In Excess of 1.5 A”. Let’s take the 1.5A. Then the power supply can deliver 3V*1.5A = 4.5W. However, at the input, there will be 9V*1.5A = 13.5W. The LM317 will be consuming 9W itself.

    • Stan says:

      I found out the hard way thees type of regulators are not useable for battery applications unless you use a real power switch (ie no soft power) because the draw 7ma just sitting there doing nothing. A cmos low quiescent current (in the nano amp range) regulator is a better choice..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 96,388 other followers