user24: Is it possible to have more than 14 output pins on the Arduino, I am working on a project in which I need to light up several LEDs individually. I only have an Arduino Uno, and I don't want to get a Mega. 

user889: For a class project I used a CD4024 and two Arduino pins to drive a 7-segment display.
There are some caveats to this approach. For example, to write a high value to the first output of a ripple counter only requires a reset and toggling the clock pin twice. But if you want to write high to all n pins requires toggling the clock pin 2n times, and during that time all the other pins are constantly toggling on and off.
If your application can deal with these limitations and you're short on pins, it's another option.
Bonus answer: there are a lot of examples of multiplexing inputs here, many of which also apply to multiplexing outputs.

user3917: With a bit of work (installing a different bootloader) an additional seven I/O lines are available on an Uno, on the ICSP1 and JP2 headers.  The replacement bootloader is called HoodLoader2.  It allows you to install sketches on both the Atmega328 and Atmega16U2 on an Uno.  Dealing with multiple processors would be the main complication from using this method.
On an Uno, the ICSP1 and JP2 headers connect to pins PB1...PB7 of the Atmega16U2.  In addition the Atmega16U2 has about 9 I/O pins with no connection to the circuit board.  A person working under a microscope might be able to attach wires to a total of 18 I/O pins on the 16U2, while leaving three other I/O pins attached to their ordinary connections.
HoodLoader2 also works on Mega boards.

user29026: There is a wealth of good answers here, but if you costed your time you'd find it cheaper to buy a Mega.
My 3/2-d worth.

user304: If it's all about LEDs, what about WS2812B LED strips, or just the driver chips themselves? You can control a virtually unlimited number of LEDs using just one pin! 
Although people are use to these in strips, they are available as standalone LEDs (known as neo pixels on Adafruit). Or if you're only driving a single colour, each WS2811 chip could control 3 LEDs by using each of the RGB outputs for a single LED each. 
I recently just created created a project that uses 5 such LEDs: Door1 open/closed, Door2 open/closed, motor1 active, motor2 active and power. The "active" LEDs are dual purpose since I have red being the input from active motor and green being active flag inside the Arduino.  
Point being, with 1 pin and the library installed, you can control any number of LEDs 

user6936: I do not claim this method for my own, but I found this neat trick on the webpage MUX-DEMUX: CD4051 Parlor Tricks
Whatever method you choose to use to drive outputs or read inputs (shift registers, multiplexors or the straightforward direct use of the Arduino pins themselves) you can DOUBLE the number of outputs or inputs by a clever use of parallel circuit pairs (to form a dual input or output bank), employing diodes in opposing senses on each parallel branch, and switching the inputs/outputs to high and low.
To illustrate the method for outputs (LEDs in this case, note that the extra diodes are not required):


If you consider the pair of LEDs in this example to be a "bank", and
  you want to light LED_0, you need to set PIN 17 to HIGH, and PIN 18 to
  LOW. (The pin numbers are confusing, but they match the later example
  so bare with me). To light LED_1, you just reverse the PINS. The diode
  nature of LEDs keeps the current from flowing the opposite direction
  keeping the other one off.

To illustrate the method for inputs (CdSs in this case, note that the extra diodes are required):


This gets a little more complicated if you want to do an analog read
  on a CdS light sensor. First, you need to add a diode to each sensor
  to control the flow. Second, since you are reading values, you need to
  pull the inputs high or low to keep them from floating. Being a lazy
  person, I'm going to pull them high using the internal pull-up
  resistors. To read CdS_0, you set PIN 17 mode to OUTPUT and set it to
  LOW. This makes it the ground. Then you set PIN 18 mode to INPUT and
  set it to HIGH to engage the pull-up resistor. Now you are set to do a
  read on PIN 18 (a.k.a. analog pin 4). To access the other sensor, just
  switch the modes and outputs.

So, if you have a CD4051 8 port multiplexor, using 5 pins on the Arduino (instead of the usual 3), you can obtain 16 inputs or outputs, or a mix of the two.

Likewise, if you have a 4067 16 port multiplexor you can obtain 32 inputs or outputs, or a mix of the two.
An example sketch would be:
/*
 * Example of getting 16 i/o from 5 pins using a CD4051
 *
 * Based on tutorial and code by david c. and tomek n.* for k3 / malmö högskola
 * http://www.arduino.cc/playground/Learning/4051?action=sourceblock&ref=1
 */ 


int selPin[] = { 14, 15, 16 }; // select pins on 4051 (analog A0, A1, A2)
int commonPin[] = { 17, 18};   // common in/out pins (analog A3, A4)
int led[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW };  // stores eight LED states
int CdSVal[] = { 0, 0, 0, 0 }; // store last CdS readings
int cnt = 0;  // main loop counter
int persistDelay = 100; // LED ontime in microseconds


void setup(){
  Serial.begin(9600);  // serial comms for troubleshooting (always)
  for(int pin = 0; pin < 3; pin++){ // setup select pins
    pinMode(selPin[pin], OUTPUT);
  } 
}


void loop(){
  flashLEDs();
  if (cnt == 0){
    for(int x; x < 8; x++){
      led[x] = random(2);
    }
  }
  cnt++;
  if (cnt > 100) { cnt = 0; }
}


void flashLEDs() {
  for(int pin = 0; pin < 2; pin++) {  // set common pins low
    pinMode(commonPin[pin], OUTPUT);
    digitalWrite(commonPin[pin], LOW);
  } 
  for (int bank = 0; bank < 4; bank++) {
    for(int pin = 0; pin < 3; pin++) { // parse out select pin bits
      int signal = (bank >> pin) & 1;  // shift  & bitwise compare
      digitalWrite(selPin[pin], signal);
    }
    if (led[bank * 2]){        // first LED
      digitalWrite(commonPin[0], HIGH);  // turn common on
      delayMicroseconds(persistDelay);   // leave led lit
      digitalWrite(commonPin[0], LOW);   // turn common off
    } 
    if (led[bank * 2 + 1]){     // repeat for second LED
      digitalWrite(commonPin[1], HIGH);
      delayMicroseconds(persistDelay);
      digitalWrite(commonPin[1], LOW); 
    }
  } 
}

Like I said in the first line, the full explanation can be found on MUX-DEMUX: CD4051 Parlor Tricks

user89: As you wrote already already, you can use all pins, including TX and RX as digital output. I did that a while ago for a demonstrator and recorded a video - 20 LEDS on 20 pins - of this rather nonsensical project. 
As described by Peter R. Bloomfield here, you a have to disconnect TX and RX for upload. Moreover, you're out of pins to read sensors for possible interactivity and have to make sure that the total current limit isn't reached. Not to forget that you're limited to 5V leds if you drive them directly with your Arduino.
The use of shift registers in general and the 595, described by Ricardo is therefore highly recommended. 

They are cheap!
It's rather easy to cascade them.
A lot of speed can be gained when you use hardware-SPI.

I used them a while ago when I realized the soldering and programming part of Kawaii me (text of the link is in German) of the upcycling artist Dominik Jais.
Here, just a bunch of 595 were used to drive a display of 8x11 leds. Since the leds were cut from a stripe of 12V SMD leds, an additional power supply and some UDN2803A Darlington arrays, hooked to the output pins of the shift registers, were necessary.
Other general methods would include the use of PCF8574(A) 8bit port expanders, which are controlled via the I2C bus.
Anyway, I'd give the 595 shift registers a try first.
If you need to control a couple of RGB leds, however, you might want to look for more specialized solutions. Some RGB leds come with their own WS2812. These fine pieces can be cascaded (1-Wire bus) and are addressed via their position in the chain.

user87: In addition to Ricardo's answer, what Wikipedia states on shift registers:

One of the most common uses of a shift register is to convert between serial and parallel interfaces. [...] SIPO registers are commonly attached to the output of microprocessors when more General Purpose Input/Output pins are required than are available. This allows several binary devices to be controlled using only two or three pins, but slower than parallel I/O.

In the article Ricardo linked you can see the diagram of the shift register.

What happens here is that you put the data of the 8 pins in a sequence and for each clock tick the shift register will shift (move the binary data from each latch to the next one) until it "makes a circle" i.e. the first bit arrives to the last pin. Shift registers also have an input where you can turn on/off the shifting so the status can be kept after the data is shifted to the position. For a simple demonstration see the following animation.

Here the red light is the serial input and the green ones are showing the state of the latches in this simplified SIPO shift register. After the data shifted to place shifting can be turned off and you can read the pins. In this example I shifted out 10101011.
From these examples you can realize that serial transfer will be slower than parallel, because you have to wait for the shift register to shift the bits to their place. You will have to wait the same amount of clock tick as many bits you want to load. This is one of the many reasons why you can't chain them indefinitely, because loading would take forever.

user42: Shift registers have been mentioned in other answers, and they are definitely an excellent choice for many projects. They are cheap, simple, moderately fast, and can typically be chained together to add more outputs. However, they have the downside that they usually need exclusive use of several pins (between 2 and 4, depending on how you set them up).
An alternative is to use more advanced port expanders, such as the 16-bit MCP23017 and MCP23S17. These support I2C and SPI respectively, which means you can place them on a bus with several other devices (potentially of different types). Each device on the bus can be individually addressed, meaning you only need 2 or 3 pins to talk to all of them. The update speeds are typically extremely fast, so you're unlikely to experience significant latency (i.e. transmission delays) in an Arduino project.
At a low level, using I2C or SPI is substantially more complicated than a simple shift register. However, there is library code for Arduino to take care of that for you. See this question, for example: How do I use I2C devices with Arduino?

user84: If you want to drive LEDs, then you can also use a MAX7219 that can drive 64 LEDs, without extra circuitry (no need for transistor to amplify signal).
Driving a MAX7219 requires only 3 output pins on Arduino.
Also, you can find a few Arduino libraries for it.
You can also chain several of them if you need to power more than 64 LEDs.
I have used it successfully for multiple 7-segment LED displays.
Downside: it is expensive (about $10).

user296: You can use Charlieplexing. With this technique you can directly drive n*(n-1) LED's from n pins. So with 3 pins you can drive 6 LED's, 4 pins - 12 LED's, 5 pins - 20 LED's and so on.
Exemple: 
Six LED's on 3 Pins
PINS        LEDS
0 1 2   1 2 3 4 5 6
0 0 0   0 0 0 0 0 0
0 1 Z   1 0 0 0 0 0
1 0 Z   0 1 0 0 0 0
Z 0 1   0 0 1 0 0 0
Z 1 0   0 0 0 1 0 0
0 Z 1   0 0 0 0 1 0
1 Z 0   0 0 0 0 0 1
0 0 1   0 0 1 0 1 0
0 1 0   1 0 0 1 0 0
0 1 1   1 0 0 0 1 0
1 0 0   0 1 0 0 0 1
1 0 1   0 1 1 0 0 0
1 1 0   0 0 0 1 0 1
1 1 1   0 0 0 0 0 0


You can see a better tutorial here.

user10794: I2C (Wire)
You can use the I2C protocol (Wire library) to connect to other devices such as port-expanders. For example, the MCP23017. 
I used one of those chips to connect to an LCD board. The MCP23017 has 16 ports, which can be configured as inputs or outputs. As inputs they can raise interrupts if desired.
Example of connecting 13 of those 16 to the LCD:

Now we connect to the Arduino using only 2 wires (SDA/SCL) plus power and ground:


Some third-party manufacturers have made boards with 4 x MCP23017 on them, this gives you 64 inputs/outputs:


Multiplexers
You can use analog multiplexers like the 74HC4051 (8 ports) or the 74HC4067 (16 ports) to connect one pin to one of the 8/16 ports (but only one at a given time), like this:

These are bi-directional, so can be used as an input or output expander.

SPI with 74HC595
Using SPI you can send fast serial data to a shift register, such as the 74HC595. These can be daisy chained together. In this example I am controlling 32 LEDs with only 3 I/O pins (MOSI/MISO/SCK) plus power and ground.


I found inside a commercial LED sign that the 72 LEDs were driven by 74HC595 chips.

This had 9 chips driving the columns (9 x 8 = 72 LEDs) and one chip driving the rows, in a multiplexed configuration.

SPI with MAX7219
If you just want to drive LEDs you can usually multiplex them. The MAX7219 simplifies that by being designed to drive LED matrixes, for example 7-segment displays:

Or 64-LED matrixes:

In both cases these can be daisy-chained together, for example:

All those examples only use 3 pins of the Arduino (MOSI/MISO/SCK) plus power and ground.

SPI with MCP23S17
The 16-port port expander mentioned earlier (MCP23017) also comes in an SPI variant (MCP23S17), which does virtually identical things. It uses one more wire, but would be faster.

Other protocols
LED strips (like the NeoPixel ones) have their own protocols. There was a post on Youtube by Josh Levine where the author drove over 1000 pixels with a Duemilanove!

References

I2C and MCP23017
MCP23017 and graphical LCD
74HC4051 multiplexer / demultiplexer
SPI
Hacking a scrolling LED strip
Using a 74HC595 output shift register as a port-expander
Interfacing LED displays with the MAX7219 driver


user24: There are two ways you can get more pins out of an arduino.
The first way is by using the Analog pins as digital output pins, which is really easy to do. All you need to do is refer to A0-A5 as pins 14,15,16,17,18,19. For example to write high to pin A0 just use digitalWrite(14, HIGH).
The other way to get more pins out of the Arduino is by using a Shift Register. To do this I recommend using the EZ-Expander Shield, which allows you to use digitalWrite([20-35], HIGH) when you import the EZ-Expander Library. This shield however only allows the pins to be used as outputs only and uses pins 8,12 and 13 to control the shift registers. 
The great thing is, is that you can use both of the two methods above together, without any problems.

user46: A common way to expand the set of available output pins on the Arduino is to use shift registers like the 74HC595 IC (link to datasheet).
You need 3 pins to control these chips: 

Clock
Latch
Data

In a program, you pass on the data one bit at a time to the shift register using the shiftOut() command, like so:
shiftOut(dataPin, clockPin, data); 

With that command, you set each of the 8 outputs on the 595 IC with the 8 bits in the data variable.
With one 595, you gain 5 pins (8 on the IC, but you spend 3 to talk to it). To get more outputs, you can daisy-chain a series of 595 together, by connecting its serial-out pin, to the data pin of the next one. You also must connect together the clock and latch pins of all of the 595 ICs.
The resulting circuit (using one 595) would look like this:

The figure above was taken from this codeproject.com webpage:

Arduino Platform - Working with Shift Registers

The latch pin is used to keep the 595 outputs steady while you are shifting out data into it, like so:
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, data); 
digitalWrite(latchPin, HIGH);


24: <p>Is it possible to have more than 14 output pins on the Arduino, I am working on a project in which I need to light up several LEDs individually. I only have an Arduino Uno, and I don't want to get a Mega. </p>
 889: <p>For a <a href="https://github.com/hoosierEE/MicroPiano/blob/master/keykey/my_functions.ino#L106-L115" rel="nofollow">class project</a> I used a CD4024 and two Arduino pins to drive a 7-segment display.</p>

<p>There are some caveats to this approach. For example, to write a <code>high</code> value to the first output of a ripple counter only requires a <code>reset</code> and toggling the clock pin twice. But if you want to write <code>high</code> to all n pins requires toggling the clock pin 2<sup>n</sup> times, and during that time all the other pins are constantly toggling on and off.</p>

<p>If your application can deal with these limitations and you're short on pins, it's another option.</p>

<p>Bonus answer: there are a lot of examples of multiplexing inputs <a href="http://www.openmusiclabs.com/learning/digital/input-matrix-scanning/" rel="nofollow">here</a>, many of which also apply to multiplexing outputs.</p>
 3917: <p>With a bit of work (installing a different bootloader) an additional seven I/O lines are available on an Uno, on the ICSP1 and JP2 headers.  The replacement bootloader is called <a href="http://blog.atmel.com/2014/12/01/using-the-power-of-two-mcus-on-an-arduino-board/" rel="nofollow">HoodLoader2</a>.  It allows you to install sketches on both the Atmega328 and Atmega16U2 on an Uno.  Dealing with multiple processors would be the main complication from using this method.</p>

<p>On an Uno, the ICSP1 and JP2 headers connect to pins PB1...PB7 of the Atmega16U2.  In addition the Atmega16U2 has about 9 I/O pins with no connection to the circuit board.  A person working under a microscope might be able to attach wires to a total of 18 I/O pins on the 16U2, while leaving three other I/O pins attached to their ordinary connections.</p>

<p>HoodLoader2 also works on Mega boards.</p>
 29026: <p>There is a wealth of good answers here, but if you costed your time you'd find it cheaper to buy a Mega.</p>

<p>My 3/2-d worth.</p>
 304: <p>If it's all about LEDs, what about WS2812B LED strips, or just the driver chips themselves? You can control a virtually unlimited number of LEDs using just one pin! </p>

<p>Although people are use to these in strips, they are available as standalone LEDs (known as neo pixels on Adafruit). Or if you're only driving a single colour, each WS2811 chip could control 3 LEDs by using each of the RGB outputs for a single LED each. </p>

<p>I recently just created created a project that uses 5 such LEDs: Door1 open/closed, Door2 open/closed, motor1 active, motor2 active and power. The "active" LEDs are dual purpose since I have red being the input from active motor and green being active flag inside the Arduino.  </p>

<p>Point being, with 1 pin and the library installed, you can control any number of LEDs </p>
 6936: 

<p>I do not claim this method for my own, but I found this neat trick on the webpage <a href="http://dawson-station.blogspot.com/2010/01/mux-demux-cd4051-parlor-tricks.html" rel="noreferrer">MUX-DEMUX: CD4051 Parlor Tricks</a></p>

<p>Whatever method you choose to use to drive outputs or read inputs (shift registers, multiplexors or the straightforward direct use of the Arduino pins themselves) you can DOUBLE the number of outputs or inputs by a clever use of parallel circuit pairs (to form a dual input or output <em>bank</em>), employing diodes in opposing senses on each parallel branch, and switching the inputs/outputs to high and low.</p>

<p>To illustrate the method for outputs (LEDs in this case, note that the extra diodes are not required):</p>

<p><img src="https://i.stack.imgur.com/nb0Mi.png" alt="LED bank"></p>

<blockquote>
  <p>If you consider the pair of LEDs in this example to be a "bank", and
  you want to light LED_0, you need to set PIN 17 to HIGH, and PIN 18 to
  LOW. (The pin numbers are confusing, but they match the later example
  so bare with me). To light LED_1, you just reverse the PINS. The diode
  nature of LEDs keeps the current from flowing the opposite direction
  keeping the other one off.</p>
</blockquote>

<p>To illustrate the method for inputs (CdSs in this case, note that the extra diodes are required):</p>

<p><img src="https://i.stack.imgur.com/m11CU.png" alt="CdS bank"></p>

<blockquote>
  <p>This gets a little more complicated if you want to do an analog read
  on a CdS light sensor. First, you need to add a diode to each sensor
  to control the flow. Second, since you are reading values, you need to
  pull the inputs high or low to keep them from floating. Being a lazy
  person, I'm going to pull them high using the internal pull-up
  resistors. To read CdS_0, you set PIN 17 mode to OUTPUT and set it to
  LOW. This makes it the ground. Then you set PIN 18 mode to INPUT and
  set it to HIGH to engage the pull-up resistor. Now you are set to do a
  read on PIN 18 (a.k.a. analog pin 4). To access the other sensor, just
  switch the modes and outputs.</p>
</blockquote>

<p>So, if you have a CD4051 8 port multiplexor, using 5 pins on the Arduino (instead of the usual 3), you can obtain 16 inputs or outputs, or a mix of the two.</p>

<p><img src="https://i.stack.imgur.com/H8E2F.png" alt="16 outputs/inputs using a CD4051"></p>

<p>Likewise, if you have a 4067 16 port multiplexor you can obtain 32 inputs or outputs, or a mix of the two.</p>

<p>An example sketch would be:</p>

<pre class="lang-C++ prettyprint-override"><code>/*
 * Example of getting 16 i/o from 5 pins using a CD4051
 *
 * Based on tutorial and code by david c. and tomek n.* for k3 / malmö högskola
 * http://www.arduino.cc/playground/Learning/4051?action=sourceblock&amp;ref=1
 */ 


int selPin[] = { 14, 15, 16 }; // select pins on 4051 (analog A0, A1, A2)
int commonPin[] = { 17, 18};   // common in/out pins (analog A3, A4)
int led[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW };  // stores eight LED states
int CdSVal[] = { 0, 0, 0, 0 }; // store last CdS readings
int cnt = 0;  // main loop counter
int persistDelay = 100; // LED ontime in microseconds


void setup(){
  Serial.begin(9600);  // serial comms for troubleshooting (always)
  for(int pin = 0; pin &lt; 3; pin++){ // setup select pins
    pinMode(selPin[pin], OUTPUT);
  } 
}


void loop(){
  flashLEDs();
  if (cnt == 0){
    for(int x; x &lt; 8; x++){
      led[x] = random(2);
    }
  }
  cnt++;
  if (cnt &gt; 100) { cnt = 0; }
}


void flashLEDs() {
  for(int pin = 0; pin &lt; 2; pin++) {  // set common pins low
    pinMode(commonPin[pin], OUTPUT);
    digitalWrite(commonPin[pin], LOW);
  } 
  for (int bank = 0; bank &lt; 4; bank++) {
    for(int pin = 0; pin &lt; 3; pin++) { // parse out select pin bits
      int signal = (bank &gt;&gt; pin) &amp; 1;  // shift  &amp; bitwise compare
      digitalWrite(selPin[pin], signal);
    }
    if (led[bank * 2]){        // first LED
      digitalWrite(commonPin[0], HIGH);  // turn common on
      delayMicroseconds(persistDelay);   // leave led lit
      digitalWrite(commonPin[0], LOW);   // turn common off
    } 
    if (led[bank * 2 + 1]){     // repeat for second LED
      digitalWrite(commonPin[1], HIGH);
      delayMicroseconds(persistDelay);
      digitalWrite(commonPin[1], LOW); 
    }
  } 
}
</code></pre>

<p>Like I said in the first line, the full explanation can be found on <a href="http://dawson-station.blogspot.com/2010/01/mux-demux-cd4051-parlor-tricks.html" rel="noreferrer">MUX-DEMUX: CD4051 Parlor Tricks</a></p>
 89: <p>As you wrote already already, you can use all pins, including TX and RX as digital output. I did that a while ago for a demonstrator and recorded a video - <a href="http://www.youtube.com/watch?v=ibhoqUkiSys" rel="nofollow noreferrer">20 LEDS on 20 pins</a> - of this rather nonsensical project. </p>

<p>As described by <em>Peter R. Bloomfield</em> <a href="https://arduino.stackexchange.com/questions/85/why-cant-i-upload-a-sketch-while-other-components-devices-are-connected-to-my-u">here</a>, you a have to disconnect TX and RX for upload. Moreover, you're out of pins to read sensors for possible interactivity and have to make sure that the total current limit isn't reached. Not to forget that you're limited to 5V leds if you drive them directly with your Arduino.</p>

<p>The use of shift registers in general and the 595, described by <em>Ricardo</em> is therefore highly recommended. </p>

<ul>
<li>They are cheap!</li>
<li>It's rather easy to cascade them.</li>
<li>A lot of speed can be gained when you use hardware-SPI.</li>
</ul>

<p>I used them a while ago when I realized the soldering and programming part of <a href="http://www.heise.de/hardware-hacks/projekte/Kawaii-me-2073147.html" rel="nofollow noreferrer">Kawaii me</a> (text of the link is in German) of the upcycling artist <em>Dominik Jais</em>.</p>

<p>Here, just a bunch of <strong>595</strong> were used to drive a display of 8x11 leds. Since the leds were cut from a stripe of 12V SMD leds, an additional power supply and some <strong>UDN2803A</strong> Darlington arrays, hooked to the output pins of the shift registers, were necessary.</p>

<p>Other general methods would include the use of PCF8574(A) 8bit port expanders, which are controlled via the I2C bus.</p>

<p>Anyway, I'd give the 595 shift registers a try first.</p>

<p>If you need to control a couple of RGB leds, however, you might want to look for more specialized solutions. Some RGB leds come with their own <strong>WS2812</strong>. These fine pieces can be cascaded (1-Wire bus) and are addressed via their position in the chain.</p>
 87: <p>In addition to <a href="https://arduino.stackexchange.com/users/46/ricardo">Ricardo</a>'s answer, what Wikipedia states on <a href="http://en.wikipedia.org/wiki/Shift_register#Uses" rel="noreferrer">shift registers</a>:</p>

<blockquote>
  <p>One of the most common uses of a shift register is to convert between serial and parallel interfaces. [...] SIPO registers are commonly attached to the output of microprocessors when more General Purpose Input/Output pins are required than are available. This allows several binary devices to be controlled using only two or three pins, but slower than parallel I/O.</p>
</blockquote>

<p>In the <a href="http://www.codeproject.com/Articles/144606/Arduino-Platform-Working-with-Shift-Registers" rel="noreferrer">article</a> Ricardo linked you can see the diagram of the shift register.</p>

<p><img src="https://i.stack.imgur.com/fnNDa.png" alt="Shift register diagram"></p>

<p>What happens here is that you put the data of the 8 pins in a sequence and for each clock tick the shift register will shift (move the binary data from each latch to the next one) until it "makes a circle" i.e. the first bit arrives to the last pin. Shift registers also have an input where you can turn on/off the shifting so the status can be kept after the data is shifted to the position. For a simple demonstration see the following animation.</p>

<p><img src="https://i.stack.imgur.com/JgnIV.gif" alt="Shift register animation"></p>

<p>Here the red light is the serial input and the green ones are showing the state of the latches in this simplified <a href="http://en.wikipedia.org/wiki/Shift_register#Serial-in.2C_parallel-out_.28SIPO.29" rel="noreferrer">SIPO shift register</a>. After the data shifted to place shifting can be turned off and you can read the pins. In this example I shifted out <code>10101011</code>.</p>

<p>From these examples you can realize that serial transfer will be slower than parallel, because you have to wait for the shift register to shift the bits to their place. You will have to wait the same amount of clock tick as many bits you want to load. This is one of the many reasons why you can't chain them indefinitely, because loading would take forever.</p>
 42: <p>Shift registers have been mentioned in other answers, and they are definitely an excellent choice for many projects. They are cheap, simple, moderately fast, and can typically be chained together to add more outputs. However, they have the downside that they usually need exclusive use of several pins (between 2 and 4, depending on how you set them up).</p>

<p>An alternative is to use more advanced port expanders, such as the <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf" rel="nofollow noreferrer">16-bit MCP23017 and MCP23S17</a>. These support I2C and SPI respectively, which means you can place them on a bus with several other devices (potentially of different types). Each device on the bus can be individually addressed, meaning you only need 2 or 3 pins to talk to all of them. The update speeds are typically extremely fast, so you're unlikely to experience significant latency (i.e. transmission delays) in an Arduino project.</p>

<p>At a low level, using I2C or SPI is substantially more complicated than a simple shift register. However, there is library code for Arduino to take care of that for you. See this question, for example: <a href="https://arduino.stackexchange.com/questions/158/how-do-i-use-i2c-devices-with-arduino">How do I use I2C devices with Arduino?</a></p>
 84: <p>If you want to drive LEDs, then you can also use a MAX7219 that can drive 64 LEDs, without extra circuitry (no need for transistor to amplify signal).</p>

<p>Driving a <a href="http://www.maximintegrated.com/datasheet/index.mvp/id/1339">MAX7219</a> requires only 3 output pins on Arduino.
Also, you can find a few <a href="http://playground.arduino.cc/Main/LedControl">Arduino libraries</a> for it.</p>

<p>You can also chain several of them if you need to power more than 64 LEDs.</p>

<p>I have used it successfully for multiple 7-segment LED displays.</p>

<p>Downside: it is expensive (about $10).</p>
 296: <p>You can use <a href="http://en.wikipedia.org/wiki/Charlieplexing" rel="noreferrer">Charlieplexing</a>. With this technique you can directly drive <code>n*(n-1)</code> LED's from n pins. So with 3 pins you can drive 6 LED's, 4 pins - 12 LED's, 5 pins - 20 LED's and so on.</p>

<p>Exemple: </p>

<p>Six LED's on 3 Pins</p>

<pre><code>PINS        LEDS
0 1 2   1 2 3 4 5 6
0 0 0   0 0 0 0 0 0
0 1 Z   1 0 0 0 0 0
1 0 Z   0 1 0 0 0 0
Z 0 1   0 0 1 0 0 0
Z 1 0   0 0 0 1 0 0
0 Z 1   0 0 0 0 1 0
1 Z 0   0 0 0 0 0 1
0 0 1   0 0 1 0 1 0
0 1 0   1 0 0 1 0 0
0 1 1   1 0 0 0 1 0
1 0 0   0 1 0 0 0 1
1 0 1   0 1 1 0 0 0
1 1 0   0 0 0 1 0 1
1 1 1   0 0 0 0 0 0
</code></pre>

<p><img src="https://i.stack.imgur.com/Bq6H5.png" alt="enter image description here"></p>

<p>You can see a better tutorial <a href="http://www.pcbheaven.com/wikipages/Charlieplexing/" rel="noreferrer">here</a>.</p>
 10794: <h2>I<sup>2</sup>C (Wire)</h2>

<p>You can use the I<sup>2</sup>C protocol (Wire library) to connect to other devices such as port-expanders. For example, the MCP23017. </p>

<p>I used one of those chips to connect to an LCD board. The MCP23017 has 16 ports, which can be configured as inputs or outputs. As inputs they can raise interrupts if desired.</p>

<p>Example of connecting 13 of those 16 to the LCD:</p>

<p><img src="https://i.stack.imgur.com/a30M6.png" alt="MCP23017 connected to LCD screen"></p>

<p>Now we connect to the Arduino using only 2 wires (SDA/SCL) plus power and ground:</p>

<p><img src="https://i.stack.imgur.com/rDcCd.png" alt="MCP23017 connected to Arduino"></p>

<hr>

<p>Some third-party manufacturers have made boards with 4 x MCP23017 on them, this gives you 64 inputs/outputs:</p>

<p><img src="https://i.stack.imgur.com/rDTTv.png" alt="Centipede board"></p>

<hr>

<h2>Multiplexers</h2>

<p>You can use analog multiplexers like the 74HC4051 (8 ports) or the 74HC4067 (16 ports) to connect one pin to one of the 8/16 ports (but only one at a given time), like this:</p>

<p><img src="https://i.stack.imgur.com/iATER.png" alt="74HC4051 multiplexer"></p>

<p>These are bi-directional, so can be used as an input or output expander.</p>

<hr>

<h2>SPI with 74HC595</h2>

<p>Using SPI you can send fast serial data to a shift register, such as the 74HC595. These can be daisy chained together. In this example I am controlling 32 LEDs with only 3 I/O pins (MOSI/MISO/SCK) plus power and ground.</p>

<p><img src="https://i.stack.imgur.com/OSl67.jpg" alt="74HC595 driving 32 LEDs"></p>

<hr>

<p>I found inside a commercial LED sign that the 72 LEDs were driven by 74HC595 chips.</p>

<p><img src="https://i.stack.imgur.com/StXYR.jpg" alt="Scrolling LED sign"></p>

<p>This had 9 chips driving the columns (9 x 8 = 72 LEDs) and one chip driving the rows, in a multiplexed configuration.</p>

<hr>

<h2>SPI with MAX7219</h2>

<p>If you just want to drive LEDs you can usually multiplex them. The MAX7219 simplifies that by being designed to drive LED matrixes, for example 7-segment displays:</p>

<p><img src="https://i.stack.imgur.com/keI0f.jpg" alt="MAX7219 with 7-segment display"></p>

<p>Or 64-LED matrixes:</p>

<p><img src="https://i.stack.imgur.com/0119t.jpg" alt="MAX7219 with 64-LED matrix"></p>

<p>In both cases these can be daisy-chained together, for example:</p>

<p><img src="https://i.stack.imgur.com/WrL3k.jpg" alt="MAX7219 daisy-chain"></p>

<p>All those examples only use 3 pins of the Arduino (MOSI/MISO/SCK) plus power and ground.</p>

<hr>

<h2>SPI with MCP23S17</h2>

<p>The 16-port port expander mentioned earlier (MCP23017) also comes in an SPI variant (MCP23S17), which does virtually identical things. It uses one more wire, but would be faster.</p>

<hr>

<h2>Other protocols</h2>

<p>LED strips (like the NeoPixel ones) have their own protocols. There was a <a href="https://www.youtube.com/watch?v=I-lR19_kigs">post on Youtube by Josh Levine</a> where the author drove over 1000 pixels with a Duemilanove!</p>

<hr>

<h2>References</h2>

<ul>
<li><a href="http://www.gammon.com.au/i2c">I2C and MCP23017</a></li>
<li><a href="http://www.gammon.com.au/lcd">MCP23017 and graphical LCD</a></li>
<li><a href="http://www.gammon.com.au/forum/?id=11976">74HC4051 multiplexer / demultiplexer</a></li>
<li><a href="http://www.gammon.com.au/spi">SPI</a></li>
<li><a href="http://www.gammon.com.au/forum/?id=12298">Hacking a scrolling LED strip</a></li>
<li><a href="http://www.gammon.com.au/forum/?id=11518">Using a 74HC595 output shift register as a port-expander</a></li>
<li><a href="http://www.gammon.com.au/forum/?id=11516">Interfacing LED displays with the MAX7219 driver</a></li>
</ul>
 24: <p>There are two ways you can get more pins out of an arduino.</p>

<p>The first way is by using the Analog pins as digital output pins, which is really easy to do. All you need to do is refer to A0-A5 as pins 14,15,16,17,18,19. For example to write high to pin A0 just use digitalWrite(14, HIGH).</p>

<p>The other way to get more pins out of the Arduino is by using a Shift Register. To do this I recommend using the <a href="https://nootropicdesign.com/ez-expander/">EZ-Expander Shield</a>, which allows you to use digitalWrite([20-35], HIGH) when you import the EZ-Expander Library. This shield however only allows the pins to be used as outputs only and uses pins 8,12 and 13 to control the shift registers. </p>

<p>The great thing is, is that you can use both of the two methods above together, without any problems.</p>
 46: <p>A common way to expand the set of available output pins on the Arduino is to use shift registers like the 74HC595 IC (<a href="http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf" rel="noreferrer">link to datasheet</a>).</p>

<p>You need 3 pins to control these chips: </p>

<ol>
<li>Clock</li>
<li>Latch</li>
<li>Data</li>
</ol>

<p>In a program, you pass on the data one bit at a time to the shift register using the <a href="http://arduino.cc/en/tutorial/ShiftOut" rel="noreferrer">shiftOut() command</a>, like so:</p>

<pre><code>shiftOut(dataPin, clockPin, data); 
</code></pre>

<p>With that command, you set each of the 8 outputs on the 595 IC with the 8 bits in the <code>data</code> variable.</p>

<p>With one 595, you gain 5 pins (8 on the IC, but you spend 3 to talk to it). To get more outputs, you can daisy-chain a series of 595 together, by connecting its serial-out pin, to the data pin of the next one. You also must connect together the clock and latch pins of all of the 595 ICs.</p>

<p>The resulting circuit (using one 595) would look like this:</p>

<p><img src="https://i.stack.imgur.com/mUyUl.jpg" alt="Circuit using 595 shift register"></p>

<p>The figure above was taken from this <a href="http://codeproject.com" rel="noreferrer">codeproject.com</a> webpage:</p>

<ul>
<li><a href="http://www.codeproject.com/Articles/144606/Arduino-Platform-Working-with-Shift-Registers" rel="noreferrer">Arduino Platform - Working with Shift Registers</a></li>
</ul>

<p>The latch pin is used to keep the 595 outputs steady while you are shifting out data into it, like so:</p>

<pre><code>digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, data); 
digitalWrite(latchPin, HIGH);
</code></pre>
