You can easily increase number of I/O pins using an expander, e.g. PCF8574. Check
The expander can be connect using your SCL/SDA pins located next to GND/AREF pins. Arduino Playground or this(Here you can find detailed photo: blog entryhttp://forum.arduino.cc/index.php?topic=84190.0) You can connect up to 8 such expanders to extend the number of your digital pins to 64.
Once you connect it, here is a code snippet of how to use it:
#include <PCF8574.h> //library available at: https://github.com/skywodd/pcf8574_arduino_library
void setup() {
PCF8574 sensors;
sensors.begin(0x20); //0x20 means that you connected A0, A1, A2 pins of PCF8574 to the ground
sensors.pinMode(0, INPUT_PULLUP);
sensors.pinMode(1, INPUT_PULLUP);
/*...*/
}
void loop() {
byte sensorValue = sensors.digitalRead(0); //reads digital value of 1st sensor connected to pin 0 of PCF8574 expander
/*...*/
}
You can read more detailswith [this tutorial][1] (note: they are using wire interface, so the code will differ. Choose the one you prefer). [1]: http://ardugonic.blogspot.com/2010/06/icm7218a-combined-with-pcf8574-to.html