Expanding the Arduino: cheap ways to add output pins and power

Posted by Erica on Jun 9, 2010 in Electronics, Making |

For the LED stairs, I need to control 14 LED lamps and 2 sensors. From the beginning, I had in mind an Arduino as the microcontroller for this project. Although it is possible to do a primitive version of these stairs without a microcontroller, having a brain at the center gives many more options. And a basic Arduino is (relatively) inexpensive. The Arduino Pro Mini, which I am planning to use, is only $19.

Arduino Pro Mini

Arduino Pro Mini

The Pro Mini has 14 digital input/ouput pins. Each output pin can produce 5V and up to 40mA. This is more than enough for a single LED. But I will be using LED lamps that require 12V. We don’t have enough power.

Antoher issue: these pins need to control all the LED lamps plus the sensors. And if you want to do any debugging, 2 of them need to be reserved for serial communication. We don’t have enough pins.

I was able to come up with solutions to these problems. It occurred to me that the need for “more pins, more power” must be a pretty common one for micrcontroller projects in general and this might be useful for other people to know.

How to add output pins

The simplest way to increase the number of ouput pins is just to buy a bigger board. The Arduino Mega provides a whopping 54 output pins. But it will cost you: the Mega is $50. And unlike the basic Arduino, you are limited in your choices regarding form factor and input power. It’s big with lots of deluxe options and that’s what you get.

The way around this is to use the Arduino to talk to another chip, called a shift register. An example of this is the 74HC595. The Arduino takes a few pins to talk to the shift register, which has 8 output pins of its own. The Arduino tells it which ones to turn on and off. Even better, the shift registers can be daisy chained so that one Arduino can talk to multiple shift registers without using any more Arduino pins.

This does increase programming complexity because the Arduino must talk to the shift register in a specified protocol. Fortunately, there is code out there that other people have written (this is the nice thing about using a popular platform). There is an excellent tutorial on the Arduino site called ShiftOut. There is a lot of stuff on the the site but it can be very hard to find, and that was true here.

As for cost, a 74HC595 will cost $0.35 or less…much cheaper than upgrading to a Mega!

How to increase output power

I already knew the answer here: add a transistor. The output pin switches a transistor which can be used to carry much greater current and voltage. The question is, the best way to implement this. I already had a painful experience in building my Speed Vest. In order to drive the electrolumincescent wire, it was necessary to switch high voltage, AC power. For that project I blindly followed the authors’ design and soldered 13 triacs in point-to-point wiring on an Arduino shield. That was not an experience I wanted to repeat.

Integrated circuits are all about packaging transistors together, right? I should at least be able to find a chip where they shared a common input voltage and ground, which would reduce the number of connections required by a factor of 3. And if it includes the protective diodes, even better. There is a famous chip that does this, called the ULN2803A. It has eight Darlington array transistors and is designed to be controlled by the 5V logic the Arduino uses. Since there is one pin for each transistor, no programming is required.

For a nice overview of this topic, see this article on using microcontrollers with switching transistors.

Cost of the ULN2803A? I got it at Arrow for $0.51.

Doing both at once

So far so good. We could take care of everything by adding 2 shift registers and 2 Darlington arrays. Pretty good but more components than I’d like. Is it possible to find a chip to do both tasks at once? Yes.

More knowledgable readers may already be wondering about LED matrix drivers. Using an Arduino to talk to sets of LEDs is a very common task and there are no shortage of articles on this. There are some nice libraries that have been developed too. In general they were not suitable for this project because despite the word “LED” I am seeking to drive higher power devices — LED lamps. Also, the matrix paradigm imposes certain requirements as far as connections and addressing that weren’t relevant here and that I preferred to avoid.

Eventually though I found the right kind of LED driver: the M5451. It can handle 12V power and can control 35 devices with a unified brightness control. Although the brightness control isn’t required here, it is a nice feature; the right type of signal — pulse-width modulated — can extend the life of the LEDs.

Next step, find code that allows the Arduino to talk to the M5451. (I am not that interested in writing device drivers.) Fortunately this chip is used by the Lightuino, which is an open-source project that (with some modification) has the code I need.

Cost of the M5451 (also listed as MM5451 at some suppliers): $3.15.

Although the M5451 should do everything I need, I’ve ordered the other two chips as well just to see how each option works. I suspect they will be useful for future projects too. Can’t wait until everything shows up and I can start breadboarding!

Tags: , , ,


  • Kevrell says:

    Now I feel stupid. That’s celared it up for me

  • Stan says:


    What did you use for a power supply, please?



  • Erica says:

    Stan, the tradeoff of using a compact device like the Mini is that you don’t get a nice power plug — you must make it yourself. Take a look at the last photo in this post: How to add a power strip to perfboard. The power inputs for the Mini socket are wired through the power strip to a screw terminal at the edge of the perfboard. I took a regular DC adapter, cut off the plug, and stripped the ends of the wires to feed them into the screw terminal. (If you do this, it’s recommended that you cut the wires unevenly so that they are different lengths and you are a bit less likely to get an accidental short.)

    The only limit is your imagination — any power supply that fits the Mini input specifications can be used, including batteries.

  • rom says:

    Well written and straight to the point! thanks.
    time to hunt ICs on ebay!

  • Patton says:

    Can those extra pins be used as inputs?

  • Erica says:

    Patton, funny you should ask, as just yesterday I was looking at that very problem. You can’t use the shift register I mention in this post for that purpose. However there are other chips that can do it. An analog multiplexer that I am looking at now is the 74HC4052. It uses 2 digital output pins from the Arduino and 2 input pins, and in return gives you 8 analog or digital inputs that can be listened to. Costs less than 25 cents. Note that you can only listen to 2 of the 8 channels at a given time, but for most situations that is just fine. Again, much cheaper than a Mega!

  • Patton says:

    That surely is a coincidence. I like it when site owners actually respond to their comments. Thank you.

  • Patton says:

    You know what, I just thought of something that could greatly impact the project I am doing. Do you know whether or not the Arduino can activate multiple pins (“LEDs”) at the same time? For example, could you turn on every other LED simultaneously?

  • Erica says:

    You’re welcome. For your last question, yes, my code certainly has multiple LEDs turning on and off at various points. The Arduino would not be very useful otherwise.

  • Patton says:


  • Patton says:

    Hello again,

    Would you happen to know if these shift registers will make use of an internal timer? I ask because I need all 3 timers on my UNO. I’m hoping the shift registers don’t need to use a timer. Thank you.

  • Erica says:

    Patton, it’s been a while since I looked at this, so I’m going to steer you to the ShiftOut tutorial linked to in the post. It’s very detailed.

  • […] high-side switch to turn on the fan, I will use the ULN2803s I ordered when writing my post on adding power and pins to the Arduino. It’s conceptually simpler, and safer (my other version did not have kickback diodes). […]

  • Tom Turner says:

    Eric, obviously a very smart guy. I will try to to build this. Can you help me with a project of my own? I think the Ping sensors you are using may help me- I want a sensor to turn on pump to a water fall when you enter a room an turn it off when you leave. Secondly, I wanted to use a pressure sensor mat to open and close a drain valve when you stand on/off a mat. Will the ping sensor work for the first part, and if so how is this made or is there an off the shelf product that does the same?


  • Shawn says:

    Hi Erica,

    I hope you are still around. I am trying to build an led sequencer that I can use for my stairs. They will go on in sequence when a sensor is tripped and after a few seconds go off in sequence. The opposite will take place from the top of the stairs. I am aware that several people have down this and posted videos on Youtube. I am also aware of people doing the same thing on these forums. My question for you is being that I’m a newbie I am looking for the easiest/cheapest way to do this. I have researched people building sequencing circuits from scratch and without an Arduino. Could someone please direct me to the simplest/cheapest way to do this? Thanks in advance.

  • Erica says:

    Well, that’s exactly what my project does 🙂 so that’s what I’d recommend starting with.

  • talha says:

    As an intermediate level electronic hobbiest this is very useful info.

    A general question though…which IDE is best for programming embedded systems. Like i have heard a lot about stm32 that they are cheap and more powerful but i am reluctant to touch them as arduino platformis super easy and well. Would you recommend people to look here and there?

  • Erica says:

    You should look at the Eclipse IDE for Arduino now. It is extremely powerful, better than the Arduino one certainly, and free.

Leave a Reply

XHTML: You can use these tags:' <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Copyright © 2024 NovoKane All rights reserved.
Desk Mess Mirrored v1.4.5 theme from BuyNowShop.com.