How to build a simple 5V power supply on a breadboard

When I build a circuit on a breadboard, the first problem I always have is to create the 5V that will power the components. Of course there are a lot of pre-made power-supplies that you fit perfectly on the power rails of the breadboard, but I wanted something that I built myself and I can use with all my circuits. In this article I will present the power supply I came up with, as well as a step by step explanation of the circuit.

Final power supply on a breadboard
Final power supply on a breadboard

First of all, yes, there are easier options, like this pre-made breadboard power supply. But if like me, you like to build things from scratch, and to understand things you create, then you’ll probably want to dig deeper and assemble your own power supply. The price will be equivalent to this pre-made one, but you’ll get the satisfaction of a DIY circuit.

Please note that we’ll be creating a 5V power supply. If your PIC requires a different voltage, then you’ll have to create this voltage instead of the 5V, but the process is the same.

Bill of Material

  • A 9V wall adapter, with a jack barrel output. It will safely transform the high AC voltage from our wall outlet, to a 9V DC voltage that we will use. You can use an adapter that outputs a different voltage, as long as it’s between 7V and 35V. For safety reasons, I would recommend avoiding the cheap ones, as they may not protect you against short-circuits or other error of manipulation.
  • One LM7805: This is a voltage regulator that takes a DC voltage from 7V to 35V, and outputs a stable DC voltage of 5V. It is a linear regulator, which basically means the voltage is dropped as a thermal loss, inducing overheating in case we work with a “high” output current. It will not be a problem if we stay under 500mA, as the energy loss will not be enough to produce excessive heat.
  • 0.33uF and 0.1uF ceramic capacitors: one of each to decouple the input and output of the LM7805.
  • One 500mA fuse (optional): to protect the source from short-circuits.
  • A LED and a 330ohm resistor (optional): to know if the power supply is on or off.

And of course, a breadboard and some wires. I used a tiny 170 points breadboard, its size is perfect for it, and building the circuit on a separate breadboard will allow us to use it with any circuit in the future.

The jack barrel

The jack barrel we use has 3 pins, and it can be tricky to find out which one is which. On the following pictures the pins are:

  • Left pin: GND
  • Middle pin: unused
  • Right pin: 9V (or the output voltage of your wall adapter)
Breadboard jack barrel
Breadboard jack barrel
Breadboard jack barrel
Breadboard jack barrel

Wiring the regulator

The LM7805 is a 3-pin device, which will transform a 7V-35V DC input voltage into a stable 5V DC voltage. Having a stable supply voltage is essential for the microcontrollers and other integrated circuits, as a variation can cause erratic behaviors. The LM7805 can output up to 1.5A, but it produces a lot of heat at higher currents. For this reason, it’s best to add a heat sink if you use it to output more than 500mA. We will stay way under this number in this tutorial, so we don’t have to worry about it.

Pinout of the LM7805 linear voltage regulator
Pinout of the LM7805 voltage regulator

As shown on the datasheet, the 3 pins are:

  1. Input: 7V to 35V DC
  2. Ground
  3. Output: 5V DC

Take a look at the picture of the actual component to locate the pins. If you look at the regulator and can see the writings, then you have pins 1, 2 and 3 from left to right.

LM7805 linear voltage regulator
LM7805 voltage regulator

Now let’s add the two capacitors. We’ll connect the 0.33uF capacitor between the Input and Ground, and the 0.1uF capacitor between the Output and Ground. Here is a schematics of the final circuit:

5V DC power supply using a LM7805
5V DC power supply using a LM7805

And we’re done! This is all we need to have a power supply we can use to power a microcontroller.

Power supply on a breadboard
Power supply on a breadboard

Testing the voltages

Before connecting anything to our power supply, let’s test it to make sure everything is wired properly. Plug the wall adapter in the jack barrel first, then in the wall. Now with a multimeter, on a DC caliber greater than 9V (or the output voltage of your wall adapter), touch pin 1 (input) of the LM7805 with the positive test lead and pin 2 (ground) with the COM lead. It should read 9V, meaning your wall adapter works well.

Input voltage of the LM7805
Input voltage of the LM7805

Now keep the COM lead on pin 2 of the LM7805, and touch pin 3 (output) with the positive lead. It should now read 5V. Congratulations, your power supply is ready to be used!

Output voltage of the LM7805
Output voltage of the LM7805

Bonus!

This power supply is very basic, and there’s a lot of ways to make it better. I’ll present two improvements, but feel free to make your own and share them in the comments!

Add a LED to show the state of the power supply

It’s always great to know whether our power supply is on of off. Sometimes it can remind you that you forgot to unplug it after you finish working on your circuits, and sometimes it tells you that the reason your circuit is not doing anything, is simply because your power supply is off.

Connect the anode of an LED to the 5V we just created, and its cathode to a free node on your breadboard. Then add a series resistor between this new node and ground. Depending on the LED you use, you may want to try different values for the resistor. With a 3mm green LED, I used a 150ohm resistor because a 330ohm one made it too dim. Here is a schematics of the circuit:

Schematics of the power supply
Schematics of the power supply

Now the LED will be ON whenever our power supply is ready, and OFF when it’s not.

Protect your adapter from short-circuits

Although a good wall adapter will have integrated protection, it’s never a bad idea to add a level of safety. Simply add a 500mA fuse in series between the positive pin of the jack barrel and pin 1 (input) of the LM7805. If for some reason your circuit draws more than 500mA, the fuse will blow and prevent any damage to the components and adapter. You can of course choose a different value for the fuse, depending on your needs.

Power supply with fuse
Power supply with fuse
Final power supply on a breadboard
Final power supply on a breadboard

Other ideas

  • Create another supply with a different output voltage. For example, if you made a 5V power supply, also create a 3.3V one. Be sure to read the datasheet of whatever regulator you’re using, as every component is used differently.
  • Combine your two voltage sources into one. Put your 5V and 3.3V power supplies on a single breadboard, and offer the choice between them. You can use a switch or just wires. You can also plug one voltage to a power rail and the other to the other power rail of your breadboard.

As you can see, you can make it as simple or as complicated as you want. Explore different regulators, test different circuits, and be sure to post a comment to present what you created!

If you haven’t read it yet, check the tutorial about getting started with PIC microcontrollers. It explains everything you need to know to start embedded programming!

Be the first to comment

%d bloggers like this: