Tutorial: Power Supplies


When I first started playing with an Arduino, I relied on USB power. Once I got into those roaming robots, I started using a battery holder I bought with the rest of the parts. In my recent projects, I’ve used power adapters that plug into the wall. With my experiences using different ways of powering my projects, I thought I’d write a tutorial that may help someone chose a supply for their projects.

Power supplies can come in different forms that give you choice based on what’s best for your project. Making a roaming robot? Go with a 4-cell AA battery holder. How about a scarf with LEDs? The lithium ion polymer (“lipo”) battery is great for wearables because it’s light and small. Sticking up strip lights above your kitchen counter? You’ll need a power outlet adapter to drive all of those LEDs. Of course, you can stray away from what a certain power supply is typically used for, as long as it can handle whatever your project is asking for.

Battery Packs


Every maker probably has a handful of battery holders lying around at any time because they’re so easy to come by. Most of the holders I have were stripped off of old toys and electronics.

The voltage that is supplied by the pack is easily calculated by adding the voltage put out by each cell. On most batteries, a mAh, or milliamp-hour, rating will be given. This is telling you how many milliamps you can draw from the battery for an hour. For example, if you have a 3000mAh battery, you can draw 3000mA for an hour, 1500mA for two hours, etc. The higher the mAh rating, the larger the capacity of the battery and the longer your project will be powered.

Power Adapters

You also probably have a power adapter lying around from an obsolete device. Inside of the “black box” is a transformer to step down the voltage, and then a rectifier circuit to make the output DC (if the output is DC). I’ll probably try writing tutorials for transformers and rectifiers once I brush up on the material. For now, all you need to know is that the adapter is converting your outlet power into power suitable for your project or device.

IMG_0752Look for the specifications printed on the adapter. The input is always the same but you need to make sure it’s an input that works for your location. In North America, we’re looking for adapters that want 120v 60Hz power, while people in other places around the world may want to look for adapters that want 230V 50Hz power. If you’re reading this, you should know what comes out of the plug next to you.

As for the output, that will vary between project and device. It is always important to know the power your project requires. For most projects, you’ll be looking for a DC supply. It’ll need to have a voltage rating appropriate for the components in your project. It is always possible to change the voltage for parts of your project using voltage dividers or regulators (to be discussed shortly) so go with the highest voltage that is required by any of your components. It is important to consider the current draw of your project as you can cause your adapter to overheat and fail if your project begins to draw more current than the adapter is rated for.IMG_0747This was a good reminder to check the specifications carefully. I accidently picked up an adapter with an AC output…IMG_0751Some adapters allow you to change the voltage and polarity of the output.

IMG_0754It is a good idea to check your power supply with a multimeter. With the variable power supply in the previous picture, the label on the switch is not very accurate so I used my multimeter to adjust the switch to the proper position. I didn’t want to open up the project to take a picture but I still wanted a picture of my lovely multimeter so this was the best I could do. (Please see the Voltage Regulation section for an extra word on measuring your supply.)

IMG_0749Power supplies will usually come with some sort of connector at the end of it. Just remember that no matter the shape of these connectors, it always leads to a couple of wires. I don’t bother looking at the connectors anymore because I end up chopping them off and stripping the wires. If you want to keep the connector, you can pick up a female connector to add to your project so that you can easily plug and unplug your power.IMG_0750This supply for my PLC shows the symbol for DC power, the dotted line under a solid line. The symbol for AC power is a sine wave. It also has circuitry so that it can work internationally as seen by the input rating.

Voltage Regulation


Sometimes, parts of your project may use a different voltage to one that your supply is giving you. The LM7805 is a 5v constant regulator that I use to power my Atmega 328 projects (unless I have a 5v supply). For other voltages, you can use other constant regulators or a variable one like the LM317.

If you are using an Arduino board, such as the Uno or Mega, there is an onboard regulator for you already. As long as you supply it with at least 7v DC, it will be happy. If you’re using a power adapter and it doesn’t have the correct barrel jack connector, you can strip the wires and power the Arduino through the Vin pin. Don’t forget to connect the ground too. One thing to note is that each pin on the Arduino can handle 40mA max, so you’ll need to consider the current draw of each component. That’s why people tell you to use an external power supply for servo motors because they’re one of those components that will draw a lot of current.

Switches can be added in various places around your project. Good places to put them are on your main power supply and the supply to major components that you’d ever want to cut power from. If you’re ever dealing with lots of power, be sure to check the rating of the switches.

About measuring your supply: Adapters can be regulated and unregulated. Regulated adapters have voltage regulator circuits built in them while unregulated adapters don’t.  When you measure the voltage of an unregulated adapter, the voltage may be higher. The voltage will drop as the load on it gets larger. I’ve never experienced any huge variations in measuring my supplies but it may happen and it could affect your project.


When choosing a power supply, you look for one that is an appropriate shape for your project and one that meets the power requirements of your project. It’s a good idea to have a multimeter around when building and testing your project to make sure you’re getting the correct voltage and current in the places you expect. As you always should while building something, be cautious with what you’re doing to ensure the safety of you and your project.



Let’s just forget about this project, shall we?

The animatronic head/box project never really got off the ground. I’ve been sitting in front of all of my sensors and parts, but I haven’t found any motivation to do anything with them. It always stinks to say, but this one is officially canned.

The last project on the line up is the PLC Trainer program. I usually write out a summary of what the program is going to do and other specifications so I’ll start on that soon enough. I’m thinking it’ll be another mixing tank simulation which didn’t really get completed the last time I tried because of the problems with the LEDs on the panel.

I wish I had something exciting to say. Oh well. Thanks for stopping by.

Animatronic Head project, now “The Box”

In my five project Project Lineup, I had an animatronic head project listed there. I want to move away from the usual roaming robots because I get tired with them too quickly. In the past, I’ve seen people make cool robot faces with LED matrix eyes and servos that moved it around to follow and interact with you. I wanted to try something like that.

The Shelf Lighting System project sort of drained me as I’m finding it hard to be creative. I ended up with this after 15 minutes:This is a crappy version of what I had in mind but still somewhat close, which made me even more unmotivated just looking at it. That’s why I made the change to “The Box”.

The main purpose of this project is to put to use all of the parts I currently have. The picture above shows them all: 2×16 blue LCD, RGB LED, 8-ohm speaker, photoresistor, sound sensor, temperature/humidity sensor, and a Real Time Clock. The animatronic head was going to have these parts anyway, but taking away the servos and unique form factor, compared to a box, will make things easier for me.

The kicker for this project is that it will have an accompanying Visual Basic Windows program, although it won’t be necessary to use it all the time. I’ll have info on that when I get around to starting it.

A quick note about the temperature/humidity sensor… I just found out that the prototyping PCB I used actually has a second layer that connects pads on the board. It’s hidden under the silkscreen so I didn’t know until now. It looks like there’s a shorted connection so I’m going to try and salvage the sensor and put it back on a board like the one used for the RTC.

I’ll begin testing each thing and then start combining it all together.

Project Lineup Progress Update

A week and a half ago, I made a post outlining five projects I wanted to work on. I wanted to summarize how the list is going, along with other things I’m doing, and what’s in store for the next little while.

Here are the projects that were on that list:

Light Timer Modification – Complete – This was a modification to the Light Timer project where it would automate the control of the lights based on the light in area as sensed by the photoresistor instead of the time of day. It was completed fairly quickly and is in regular use.

Light Nametag – Complete – This was a simple project where I wanted to spell out my name in LEDs. While I didn’t get the patterns to work, the result is still satisfying.

Desk Light Project – Complete – I wanted to install LEDs around my desk so that I wouldn’t have to use the ceiling light. The project was completed and is in regular use.

Animatronic Head – Starting Soon – I want to create an animatronic head that has neck motion, LED matrix eyes, and an LCD for the mouth for the basic features. I have not given it much thought past that.

PLC Trainer ProgramStarting Soon – I want to practice my ladder logic programming as I haven’t really touched it in a while. This project will likely run parallel to the Animatronic Head project. Both of these projects need more planning before I actually start either.

In addition to these projects, one additional project came up and was completed. That is the Shelf Lighting System I made for my brother. As I’ve said plenty of times, it was an exhausting project so I’m starting back with my projects a little slower than I usually do.

I want to add more things to the Featured Projects page and get more individual project pages up as well.

Besides my projects, I’m [slowly] reading a book about robotics. It’s great because it almost picks up where the George Brown College PLC program left off (which I finished a week or so ago) as the program gave a small introduction to robotics at the end. I may start writing up tutorials on the blog but that needs some more consideration. I’m also looking for a job but that’s obviously not going very well.

If you haven’t already, follow me on Google+. The posts I make there are usually behind-the-scenes look while I do things and content that doesn’t really suit the blog (usually because it’s too short).

Thanks for reading!

Name Tag Project: Completed using Plan C

The LED name tag project is complete! Two things went wrong so I fell back on backup plans. The end result is a simpler version of what it was supposed to be. The original plan was to have a standalone LED name tag, powered by an Atmega328 circuit. I didn’t have a capacitor for the voltage regulator so it wouldn’t have its own power supply, and something went wonky with the Atmega328 circuit. There’s more on that below.

IMG_0741To fix the no-voltage-regulator problem, I went back to the Desk Lighting Project to steal some power from it. In that project, I said that it was expandable simply by soldering on a couple of wires to the dip switch board. One of the switches now controls the power to the LED name tag.
IMG_0742The next step was to set up the Atmega328 chip. I’ve had great success in other projects where it worked right off the bat. This time, it didn’t. Taking out and plugging back in some capacitors got it going but it eventually started going all weird on me. The program sequences would get stuck in a for-loop forever or skip lines of code. It worked fine when it was running on the Arduino Uno. After about half an hour of trying to figure out what was wrong, I gave up and decided to let the switch control it. There won’t be any patterns, unfortunately. I have a feeling it’s the oscillator so I’ll order some more whenever I feel like it, along with those capacitors I need for the voltage regulator. I’ll take a break on these Atmega328 powered projects for a while.
IMG_0743It looks nice on the desk among my random things. In person, it looks better the further you are away from it. I think it may look better with diffused LEDs but I’m still satisfied with it.

Thanks for reading! I’ll be working on updating my Featured Projects page, as well as a post summarizing my recent projects and what I’m up to next.

Shelf Lighting System

After the nice result of the Desk Lighting System project, my brother wanted me to do the same for some shelves in the basement. It quickly turned into a larger project than I was anticipating. This was honestly one of the most stressful projects I’ve worked on in a while as I spent 7 hours non-stop for two days getting it up. The lights we got was a 5 meter white LED strip. I had to go back the next day for two reasons: I bought the wrong power supply (had AC output), and I researched more and saw I would need a mosfet transistor (some explanations on this later).

IMG_0738The first day was literally spent cutting the strip and soldering them back together. It took a long time because the pads on the strip are really small when you cut them so they broke off or the solder gave me a hard time by refusing to flow on the pad. Once that was done, I taped them on all of the shelves. That was all of day one.IMG_0733Day two was another frustrating mess. I got the circuit working using an Arduino Uno board. The final project would have a standalone Atmega328p circuit and a voltage regulator. Before I move on, I want to explain exactly what the Atmega chip is for since I didn’t use it in my last lighting project.

My brother requested a dimmer. To do that, I’d need to use the PWM, or Pulse Width Modulation, pin on the Atmega microcontroller. Basically PWM is adjusting the duty cycle of the output signal so it changes the intensity of the light as we see it. To get a dimmer light, the duty cycle is decreased, or the time on becomes less than the time off in one cycle.

To make things more complicated, the LED strip runs off of 12v, which cannot be supplied directly to the Atmega chip. That’s where the voltage regulator and  mosfet transistor comes in. The voltage regulator is a constant 5v regulator that is required for the microcontroller. The mosfet transistor is used in this case as a switch to open or close the ground connection of the LED strip. The positive connection of the LED strip goes to the 12v source. When a signal is sent to the mosfet [gate], the “switch” closes, turning the lights on. PWM still works as it’s basically opening and closing the switch really fast.

Now back to the pictures…IMG_0735I tried soldering it together. That failed. I don’t know if it’s a failure of connecting it properly or if it was because I had a wrong capacitor (which I discovered after, when I decided to just breadboard it).
IMG_0736So yeah, I took the easy way out on this one. My main worry is that something is going to fall off because it’s mounted sideways. I taped as many connections as I could so it should hold up. I’ll probably keep a close eye on it for the next few days to see how it works out in use… even though I don’t want to. I’m exhausted from this project.

IMG_0737The switch and dimmer potentiometer are solid in place. And yes, it’s another food container.

IMG_0732The final result.

Good riddance… I mean, it’s pretty amazing that everything came together in three days, but the stress was intense trying to get it to work. I have a fear that something will give.

On to the next one.