Using the Microchip MCP23017 we can add another 16 IOs to the Raspberry Pi.
The Raspberry Pi has a limited number of IO pins but does have I2C and SPI. With the Microchip MCP23017 I2C expander this can be increase by 16.
The i2c driver must be installed first.
Note : For Rev 2 board change on line
bus = smbus.SMBus(0)
bus = smbus.SMBus(1)