In recent months, we’ve worked on several projects with PIC microcontrollers, often without including a power-supply stage. We’ve taken it for granted that readers already have their own 5V supply—but that isn’t always the case. Here’s how to build one.

Building a low-power supply is remarkably straightforward today. Integrated voltage regulators make it easy and inexpensive to turn the available household AC mains voltage—110V or 220V—into a well-regulated 5V DC output.

This supply can power more than microcontroller projects. Replace the output terminal block with a USB connector, making sure the polarity is correct, and it can serve as a travel charger for gadgets that recharge through a computer’s USB port.

The supply can deliver a maximum current of 1 amp. Without a good heatsink on the LM7805 voltage regulator, however, you should draw only a little over half that maximum; otherwise, the regulator will generate too much heat. The LM7805 also has built-in thermal protection and will shut down if its temperature exceeds safe limits.

At the input, the circuit has two terminal blocks wired in series. Connect the chosen transformer’s secondary wires to one, and the on/off switch to the other. Keep in mind that switching off the supply does not disconnect the transformer from the mains. Unplug it from the wall when it isn’t in use.

The transformer output feeds a diode bridge, which rectifies the incoming current. A 470uF/16V capacitor then helps reduce some of the ripple produced by this type of rectifier. The voltage regulator is the heart of the supply, with a 0.1uF capacitor at its input and another at its output, as specified in its datasheet. The output of this stage is regulated 5V.

A second 470uF/16V capacitor filters out any small amount of ripple that remains. An LED in series with a current-limiting resistor indicates whether the supply is on.

We designed a small printed circuit board measuring just 2.5 x 5.0 centimeters, which you can make at home using the procedure we’ve already described at NeoTeo. Once the board is ready, drill the holes for the component pins. Remember that the terminal blocks, diode bridge and LM7805 have thicker pins than the other components.

Use the component-free board layout as a guide and fit the parts one at a time, taking care not to install any in the wrong orientation. When everything is in place and checked, connect the transformer and switch. Plug in the supply; if everything is correct, turning on the switch should light the “Power” LED to indicate that the supply is operating.

If you need a voltage other than 5V, you can change the voltage regulator—and, of course, the transformer. For example, an LM7812 provides 12V DC at its output. Regulators for 3V, 5V, 6V, 8V, 9V, 12V and 15V are readily available and inexpensive. They all carry the “LM78xx” designation, where “xx” is the output voltage. If your project runs on a 9V battery, simply replace the LM7805 with an LM7809 to make a supply that can replace the battery.

When changing the supply’s output voltage, remember to replace the resistor that limits the current through the “Power” LED. For 9V, you can use a 680-ohm resistor; for 12V, 1K may work.

Parts list

The parts needed are few, and they’re easy to find at an electronics store:

  • 1 transformer: 220V to 6V, or 110V to 6V depending on your country
  • 1 diode bridge rated at 50V, 1A
  • 3 two-screw terminal blocks, or 2 terminal blocks and a PCB USB connector
  • 2 470uF/16V electrolytic capacitors
  • 2 0.1uF ceramic capacitors
  • 1 220-ohm, 1/8-watt resistor
  • 1 red, 5-millimeter LED
  • 1 LM7805 voltage regulator in a TO220 package
  • 1 on/off switch

It’s a simple build, but a useful one—and sure to be appreciated by anyone just getting started in this hobby.