This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

8 Answers
8

Have you used up all your analog pins as well? They can also be used as digital input/output by just referring to them as digital pins pins 14 to 19.

After you used all of them as well you might consider using a shift register IC. These chips will convert serial data into parallel data. The 8 bit versions will take serial data on three pins and output parallel data on 8 pins, giving you 5 extra pins. A very nice explanation is done by Dave Clausen at NYC Resistor.

There is actually a possibility of overloading your arduino. Not by using too much pins, but by drawing too much current from the pins, by hooking up too much stuff to your pins. The Atmega168 datasheet says that the pins have an absolute maximum current of 40mA. This would be equivalent to two LED's in parallel. Anything more than one LED (20mA) should be switched through a transistor or transistor array. This is also explained in the video mentioned above and by Tom Igoe.

Also, the ATMega168 has a maximum current of 200mA through the Vcc and Gnd pins (each), so driving or sinking more than ten LEDs through an Arduino is also probably a bad idea (given the common current of 20mA used to light LEDs).
– LouNov 4 '09 at 21:12

With one of these, you can use a single pin to switch a much larger number of devices. It'll be slower than flipping the IO pin directly, of course, and it'll use more memory since you have to address the devices over that port (this can be traded off for more speed if you'd like).

There are many options for expanding the number of inputs and outputs you have available. For an analog input it is common to use analog multiplexers (like the 4051, available as 74HC4051 and CD4051) which allow you to switch between 8 analog sources using 3 digital lines and 1 analog input.

One commonly used option for digital IO is to add TTL (or CMOS) shift registers. Shift registers come in two main varieties, the "serial in, parallel out" (like the 74HC595) which are useful for extending the number of digital outputs your project has and "parallel in, serial out" (like the 74HC165) which allows you to add more digital inputs.

You can overload the Arduino's output by trying to 'fanout' too far. Each IC you connect to an output draws current from that output. If you load lots of ICs onto the same output (or set of outputs) they might try to draw more than the Arduino's outputs can handle. To remedy this problem you can place non-inverting buffer chips (like the 74LS07) between some of the ICs.