Electronic – Arduino: How does one extend the pins to accommodate multiple sensors

arduinoprototyping

This is a fundamental question about the Arduino system. I've been trying to find answers all day, but keep getting answers either unrelated to the Arduino or completely off topic.

I'm building a robot that consumes most of the pins on the Arduino for motor and IR sensor modules. The robot works great (Robot Starter Kit by OSEPP). Now I want to get on with adding several more sensors and an LED output module, but I've run out of pins. I've seen prototyping boards and shields that seem to extend the pin count, and I've read several articles on the address bus helping to uniquely ID all the components, but I'm lost at step one…

How does one address various input / output connectors or pins on prototyping boards?

Sorry for the noob question, but as with all tech, the simplest first steps are always the least documented. Any links to great tutorials would be greatly appreciated.

Best Answer

There is no true way to expand pins, but there are techniques you can use to exchange processing power and data for more effective pins.

Using just 3 pins and 1 chip select (slave select) pin per device you can talk to many devices over SPI (serial peripheral interface).SPI with 3 slaves]1

If the devices you want to talk to do not support SPI you can use other ICs such as a shift register that talks to over SPI and give you more effective digital IO. Daisy chained shift registers

The above picture shows an example of two 8-bit shift registers daisy chained together. Using 3 pins from the microcontroller you are able to control 16 LEDs.

You can multiply this effect even higher using a technique called multiplexing. Instead of using shift register outputs directly, you can attach components into a grid and "select" a column and row.

8x8 multiplex grid

In this case an arduino using 3 pins is able to drive two 16 shift register outputs which can drive 64 devices. This is essentially how a keyboard works.