DCDC Converter Output Voltage Controlled by PWM

About: A software developer that tinkers with electronics and 3D printing in his free time.

I needed a digitally controlled DCDC converter with a variable output voltage for a charging circuit... So I made one.

The output voltage resolution is exponentially worse the higher the voltage output. Maybe something to do with the relation of LED brightness to PWM?

Example output voltages at varied PWM:

  • PWM 100% = ~2.8v
  • PWM 25% = ~5V
  • PWM 6.25% = ~8V
  • PWM 3% = ~18V
  • PWM 0% = ~28V

Step 1: Parts

Parts that I used:

  • Cheap (~3$) ebay DCDC step-up/down converter
  • Microcontroller capable of 1kHz PWM or faster (I am using NodeMCU for added wireless capabilities)
  • White LED (flat tipped ones are the easiest to work with
  • 10k photoresistor
  • 5k resistor (I used 5.6k because its the first one I found)
  • Electrical tape


  • Heat-shrink tubing
  • Jumper wires


  • Soldering iron and solder
  • Wire stripper
  • Pliers if the potentiometer is really stuck on the converter
  • Lighter if you are using heat-shrink tubing

Step 2: Assembly

    1. Holding the LED and the photoresistor end to end, tape them in place. For a nicer look, use heat-shrink tubing instead.

    2. Solder a 5k resistor to the longer (positive) lead of the LED.

    3. Slowly pry the potentiometer off the DCDC converter while simultaneously melting the solder holding it in place on the board. This is kinda tricky. It is easiest if you rock it back and forth slowly and hold the soldering iron across all three terminals.

    4. Once the potentiometer has been removed, you should now see 2 of the three uncovered potentiometer pads are connected on the board and the last is on its own. Solder the photoresistor leads to the 2 outside pads; one lead to the 2 connected pads and the other to the pad on its own.

    5. Solder wires to the shorter (negative) LED lead and the resistor lead. I used jumper wires cut in half so I could easily connect them to arduino pins.

    Step 3: Usage

    Sending a PWM signal of 1kHz or more to the LED will flash faster than the photoresistor response time. This gives a fairly constant resistance.

    The photoresistor I used has a response time of 30ms. The PWM signal will flash the LED fast enough that the photoresistor sits a bumpy average resistance somewhere between full-on and full-off.

    Raise the PWM value to make the LED 'brighter'. This lowers the resistance of the photoresistor which tells the DCDC converter to lower the voltage.

    The opposite is true when lowering the PWM value.

    Let me know if you have any questions.



      • Tape Contest

        Tape Contest
      • Arduino Contest 2019

        Arduino Contest 2019
      • Trash to Treasure

        Trash to Treasure