Adding more pins with multiplexers and shift registers - BleepLabs/Arduino-Light-And-Sound GitHub Wiki
A multiplexer or "mux" is a switch that is digitally controlled.
We can use it to expand the Teensy’s inputs or outputs.
The 4051 is cheap and easy to use and doesn't require any other components. They work even better when they share the same digital control pins as seen here. You can also use the mux in the other direction if you'd like to have a single analogWrite pin control 8 or more LEDs.
See this code for more info. It uses the same pins as this diagram.

A shift register also you to add many more digital inputs or outputs with only 3 digital pins, no matter how many chips you use.
Adding inputs with a CD4021 or 74HC165
Adding outputs with a 74HC595