Tyre are various options once you start using up all pins.
-
Move to another uC with more pins, such as 644P, 1284P or 2560.
-
Put other devices on shared buses, such as I2C and SPI, to free up other pins. This can require use of port expanders such as the PCF8574 which gives 8 input/outputs for 2 shared pins on the uC.
-
Use a voltage divided to read multiple buttons on an Analog pin. It needs tolerances building in and debouncing.
-
Matrix buttons and make use of the Keypad library to give you up to 9 buttons on 6 pins, 16 on 4 pins, 25 on 5 pins etc. Upto 4 x 4 (8 pins) can also be used together with a PCF8574 and Keypad_I2C to get 16 buttons on 2 pins. This can be repeated on the same two I2C pins to have 32, 64, 128 buttons or more.
-
Use cheap shift registers, such as the 8 bit 74HC595, and cascade to expand input/outputs using just 3 uC pins. limited only by the processing overhead to drive the number of shift registers you incorporate.